dcsimg
how to find out error in preparestatement? sending the code
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   sam_viswanathan
Posted On:   Thursday, June 27, 2002 04:24 AM

this is my code when i use createstatement it's working fine only problem with p.statement. import java.sql.*; public class try3 { public static void main(String args[]) { Connection con; PreparedStatement stmt=null;; try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); } catch(java.lang.ClassNotFoundException e) { System.err.print("ClassNotFoundException: "); System.err.println(e.getMessage()); } try { con = DriverManager.getConnection("jdbc:odbc:sathiya","",""); //stmt = con.prepareStat   More>>


this is my code when i use createstatement it's working fine only problem with p.statement.
import java.sql.*;


public class try3 {


public static void main(String args[]) {



Connection con;

PreparedStatement stmt=null;;



try {

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");


} catch(java.lang.ClassNotFoundException e) {

System.err.print("ClassNotFoundException: ");

System.err.println(e.getMessage());

}


try {


con = DriverManager.getConnection("jdbc:odbc:sathiya","","");


//stmt = con.prepareStatement("insert into second values(null,null,1934,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,'15/7/1947','housewife','senthil','1/2/1971','kumar','3/2/1973','chitra','3/3/1975','narmada','18/6/1976','d.j.hs',1985,61,'tamil,english','d.j.h.s ',1987 ,65 ,'e,t,p,c,b,z','s.j.c.i.t ',1997,61 ,'computer,electronics ',null ,null ,null ,null ,null,null,null,null,null,null,null,null ,null,null ,null,null ,null,null,null ,null,null ,null,null,null ,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null)");

stmt=con.prepareStatement("insert into table second values(?,?,?,?,?,?,?,?,?,?, ?,?,?,?,?,?,?,?,?,?, ?,?,?,?,?,?,?,?,?,?, ?,?,?,?,?,?,?,?,?,?, ?,?,?,?,?,?,?,?,?,?, ?,?,?,?,?,?,?,?,?,?, ?,?,?,?,?,?,?,?,?,?, ?,?,?,?,?,?,?,?,?,?, ?,?,?,?,?,?,?,?,?,?, ?,?,?,?,?,?,?,?,?,?, ?,?,?,?,?,?,?,?,?,?, ?,?,?,?,?,?,?,?,?,?, ?,?,?,?,?,?,?,?,?,?, ?,?,?,?,?,?,?,?,?,?, ?,?,?,?,?,?,?,?,?,?, ?,?,?,?)",ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);

//stmt.executeUpdate("insert into second values('Mr','sathiya',1003,'sathiyam@hotmail.com','12/04/70','erode','tamilnadu','tamil','no','married','munrica','erode,tamilnadu',6160216,54741,'yes',1234567,'1/1/2000','chennai',2003,'balu',6160216,'munrica','tamil','english','tamil','hidhi','tamil,english','vis','8/7/1933','agri','gandhi','15/7/1947','housewife','senthil','1/2/1971','kumar','3/2/1973','chitra','3/3/1975','narmada','18/6/1976','d.j.hs',1985,61,'tamil,english','d.j.h.s ',1987 ,65 ,'e,t,p,c,b,z','s.j.c.i.t ',1997,61 ,'computer,electronics ',null ,null ,null ,null ,null,null,null,null,null,null,null,null ,null,null ,null,null ,null,null,null ,null,null ,null,null,null ,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null)");

stmt.executeUpdate();

// System.out.println("1 row inserted correctly"+i);



stmt.close();

con.close();


} catch(SQLException ex) {

ex.printStackTrace();

//System.err.println("SQLException: " + ex.getMessage());

}

}

}

   <<Less

Re: how to find out error in preparestatement? sending the code

Posted By:   Seshagiri_Kamalakaran  
Posted On:   Thursday, June 27, 2002 06:05 AM


Hi


I am not able to understand ur code completely

so much commented and huge number of input parameters

However,why r u using ResultSet scrollable and all in

PreparedStatement
just remove those things from Ur prepareStatement.

Ur code must look like this


PreparedStatement pstmt = con.prepareStatement();

pstmt.executeUpdate();


With Warm Regards

Sesh
About | Sitemap | Contact