Results 1 to 3 of 3

Thread: mysql procedure

  1. #1
    Sno's Avatar
    Sno
    Sno is offline Senior Member
    Join Date
    Apr 2010
    Posts
    196
    Rep Power
    5

    Default mysql procedure

    Can anyone see anything noticeably wrong?

    PHP Code:
    String query = "CALL `Airplane_Request`.`rt_ins_trip`(?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
    											    	    //1  2  3  4  5  6  7  8  9  10 11 12 13 14
    	// Insert Trip
    	cs = conn.prepareCall(query);
    											    	    
    	cs.setString(1, bsns);
    	cs.setString(2, dt);
    	cs.setString(3, mtngtm);
    	cs.setString(4, mtngwdth);
    	cs.setString(5, street);
    	cs.setString(6, city);
    	cs.setString(7, state);
    	cs.setString(8, phone);
    	cs.setString(9, status);
    	cs.setInt(10, athrzr_id);
    	cs.setString(11, cmnts);
    	cs.setString(12, cntct);
    	cs.setInt(13, cbempty);
    	
    	cs.registerOutParameter(14, Types.INTEGER);
    	cs.execute();
    	
       System.out.println(cs.getInt(14));
    PHP Code:
    java.sql.SQLException: Parameter index of 14 is out of range (1, 0)
    java.sql.SQLException: Parameter index of 14 is out of range (1, 0)
    	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1075)
    	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:989)
    	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:984)
    	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:929)
    	at com.mysql.jdbc.CallableStatement$CallableStatementParamInfo.checkBounds(CallableStatement.java:274)
    	at com.mysql.jdbc.CallableStatement.checkParameterIndexBounds(CallableStatement.java:710)
    	at com.mysql.jdbc.CallableStatement.checkIsOutputParam(CallableStatement.java:672)
    	at com.mysql.jdbc.CallableStatement.registerOutParameter(CallableStatement.java:1846)
    	at org.apache.jsp.json.json_005ftrip_jsp._jspService(json_005ftrip_jsp.java:119)
    	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
    	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
    	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
    	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
    	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    	at java.lang.Thread.run(Unknown Source)
    :rolleyes: ~ Sno ~ :rolleyes:
    '-~ B.S. Computer Science ~-'

  2. #2
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    797
    Rep Power
    6

    Default

    indexing starts from 0 only.not from 1...Just check once.
    Ramya:cool:

  3. #3
    Sno's Avatar
    Sno
    Sno is offline Senior Member
    Join Date
    Apr 2010
    Posts
    196
    Rep Power
    5

    Default

    .. still says its not valid.

    PHP Code:
    Parameter index out of range (0 < 1 ).
    PHP Code:
    cs = conn.prepareCall("CALL `Airplane_Request`.`rt_ins_trip`(?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
    											    	    
    	cs.setString(0, bsns);
    	cs.setString(1, dt);
    	cs.setString(2, mtngtm);
    	cs.setString(3, mtngwdth);
    	cs.setString(4, street);
    	cs.setString(5, city);
    	cs.setString(6, state);
    	cs.setString(7, phone);
    	cs.setString(8, status);
    	cs.setInt(9, athrzr_id);
    	cs.setString(10, cmnts);
    	cs.setString(11, cntct);
    	cs.setInt(12, cbempty);
    	
    	cs.registerOutParameter(13, Types.INTEGER);
    	cs.executeUpdate();
    :rolleyes: ~ Sno ~ :rolleyes:
    '-~ B.S. Computer Science ~-'

Similar Threads

  1. Help with while iterative procedure
    By SweetLD215 in forum New To Java
    Replies: 16
    Last Post: 10-20-2010, 06:54 AM
  2. Replies: 1
    Last Post: 09-10-2010, 03:47 PM
  3. Replies: 0
    Last Post: 02-03-2010, 08:20 AM
  4. Debug mySql stored procedure
    By ulix83 in forum NetBeans
    Replies: 0
    Last Post: 10-29-2009, 11:48 AM
  5. stored procedure
    By sankarigopi in forum JDBC
    Replies: 1
    Last Post: 11-13-2008, 04:53 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •