Hi, somebody can help me! my database is: mysql-5.0.0a-alpha the connection driver is:mysql-connector-java-3.1.1-alpha-bin.jar
I want to test stored procedure of the new feature in MySQL version 5.0. A I can call the stored procedure procPara in Window Console as next show, but when I run in procTest.java,I get error Messages. The error is at the line: CallableStatement cs=conn.prepareCall("{call procPara(?)}"); between checkpoint 1 and checkpoint 2 your answer is highly appreciated! from: NanFei --------------------------------------------------------------------- mysql> delimiter // mysql> mysql> CREATE PROCEDURE procPara(IN name varchar(16)) -> BEGIN -> SELECT note FROM kmdoc where username=name; -> END -> // Query OK, 0 rows affected (0.22 sec) mysql> call procPara("John")// +------------------------------------------+ | note | +------------------------------------------+ | mysql Manul | | Office2000 | | PDF | | PowerPoint Animation Runtime | | Office2003 | | Test Title | | Say Hello | +-----------------------------------------+ 7 rows in set (1.16 sec) Query OK, 0 rows affected (1.67 sec) mysql> ------------------------------------------------------------------------------ procTest.java as following: package km; import java.sql.*; public class procTest{ public static void main(String[] args)throws Exception { String driverConnection="jdbc:mysql://localhost/"; String catalog="mycatloge"; String user="myname"; String psw="mypsw"; String connDbUserPsw=driverConnection+catalog+ "? user="+user+"&password="+psw; try { Class.forName("com.mysql.jdbc.Driver"); } catch (ClassNotFoundException e) {} Connection conn = DriverManager.getConnection(connDbUserPsw); System.out.println("checkpoint 1"); CallableStatement cs=conn.prepareCall("{call procPara(?)}"); System.out.println("checkpoint 2"); cs.setString(1,"john"); java.sql.ResultSet rst=cs.executeQuery(); while(rst.next()){ String s=rst.getString(1); System.out.println(s); } } } Messages: checkpoint 1 java.lang.StringIndexOutOfBoundsException: String index out of range: -9 at java.lang.String.substring(String.java:1480) at com.mysql.jdbc.DatabaseMetaData$TypeDescriptor.<init>(DatabaseMetaData.java:7031) at com.mysql.jdbc.DatabaseMetaData.getCallStmtParameterTypes(DatabaseMetaData.java:6615) at com.mysql.jdbc.DatabaseMetaData.getProcedureColumns(DatabaseMetaData.java:2637) at com.mysql.jdbc.CallableStatement.determineParameterTypes(CallableStatement.java:904) at com.mysql.jdbc.CallableStatement.<init>(CallableStatement.java:72) at com.mysql.jdbc.Connection.prepareCall(Connection.java:999) at com.mysql.jdbc.Connection.prepareCall(Connection.java:978) at km.procTest.main(procTest.java:17) Exception in thread "main" -------------------------------------------------------------------------