urgent:a question about use JDBC,help me please.

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Tina

urgent:a question about use JDBC,help me please.

Post by Tina » Mon Sep 17, 2001 8:18 am

hi.
I try to insert a Date type value to a SQL table with JDBC(JdbcOdbcDriver);
the connection and preparestatement are right,then

sql="insert c_table (id,report_date,dep) values(?,?,?)";
PrepareStatement stmt=conn.prepareStatement(sql);

String a=new String("1234567");
Long a1=new Long(a);
long a2=a1.longValue();
java.sql.Date d=new java.sql.Date(a2);
java.sql.Date d2;
d2=d.valueOf("1998-9-16");

stmt.setInt(1,2);
stmt.setDate(2,d2);
stmt.setStrint(3,"developer");

the setInt and setString successful,but there something wrong with stmt.setDate(2,d2),I can't reslove it.if you know,help me please.

java.lang.NullPointerException
at sun.jdbc.odbc.JdbcOdbc.SQLBindInParameterDate(JdbcOdbc.java:306)
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.setDate(JdbcOdbcPreparedState
ment.java:605)

Thanks in advance!
Tina

David Gilbert

RE: urgent:a question about use JDBC,help me pleas

Post by David Gilbert » Mon Sep 17, 2001 2:37 pm

Tina,

Your question is more likely to get answered if you post it in the JDBC Forum on the Java Developer Connection:

http://forum.java.sun.com/forum.jsp?forum=48

Regards,

DG.

Tina

RE: urgent:a question about use JDBC,help me pleas

Post by Tina » Tue Sep 18, 2001 3:03 am

DG,

Thank you very much,you are so kindly.

Best wish,
Tina.

Locked