Prepared statement exception

hello guys,

My code is:

publicstaticvoid addPrepOrder(String src_db,

int orderId,

String supplierName,

String orderDate)

{

try{

Connection con= DriverManager.getConnection(src_db);

Statement stmt = con.createStatement();

String SQL ="insert into tblOrder(supplierName,orderDate)" +

" values(?,?)";

PreparedStatement pstmt = con.prepareStatement(SQL);

pstmt.setString(1, supplierName);

pstmt.setString(2, orderDate);

pstmt.executeUpdate(SQL);

stmt.close();

con.close();

}catch (SQLException e){

e.printStackTrace();

}

}

and it throws the following exception:

java.sql.SQLException: Driver does not support this function

at sun.jdbc.odbc.JdbcOdbcPreparedStatement.executeUpdate(Unknown Source)

at AcomDBPack.Utilities.addPrepOrder(Utilities.java:83)

at AcomDBPack.Utilities.runSimulation(Utilities.java:125)

at AcomDBPack.acomMain.main(acomMain.java:62)

Any idea whats wrong? Its the first time i try to use prepared statements. Is there something wrong with that?

BR

Charalambos

[1582 byte] By [Charalambosa] at [2007-11-26 15:14:07]
# 1
Driver does not support this functioncheck if your driver support that kind of transactions
G_Abubakra at 2007-7-8 9:05:39 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2
i m sorry, i might be a bit stupid here but how can i check if the driver supports this kind of transactions?
Charalambosa at 2007-7-8 9:05:39 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3
we all started like that!Check on their website for API specification or Documentation. It give you all Classes, method even examples how to use the drivers.
G_Abubakra at 2007-7-8 9:05:39 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 4

The only problem I can see with that code is that the "orderDate" column might actually be a date column and not text. Everything else looks perfectly normal to me. So maybe it's the string-to-date conversion that is failing. Converting the String to a java.util.Date (via SimpleDateFormat) and making a java.sql.Date or java.sql.Timestamp object from that might solve the problem. Use the setDate or setTimestamp method of your prepared statement instead.

DrClapa at 2007-7-8 9:05:39 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 5

> we all started like that!

>

> Check on their website for API specification or

> Documentation. It give you all Classes, method even

> examples how to use the drivers.

The driver in this case is the JDBC-ODBC bridge.

It certainly does support this kind of SQL statement, so something else is wrong. DrClap's advice is excellent - check that first. Why pass in a date String? Why not pass in a java.util.Date?

%

duffymoa at 2007-7-8 9:05:39 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...