Suggest please why the following code throws an exception:
...
Connection con = DriverManager.getConnection("jdbc:odbc:DB;uid=sa;");
PreparedStatement ps = con.prepareStatement("INSERT INTO log VALUES (?,
1)");
ps.setDate(1, new java.sql.Date(System.currentTimeMillis()));
ps.executeUpdate();
....
Exception in thread "main" java.sql.SQLException: [Microsoft][ODBC SQL
Server Dr
iver]Optional feature not implemented
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6031)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:6188)
at sun.jdbc.odbc.JdbcOdbc.SQLBindInParameterDate(JdbcOdbc.java:752)
at
sun.jdbc.odbc.JdbcOdbcPreparedStatement.setDate(JdbcOdbcPreparedState
ment.java:833)
Here is the table definition SQL statement:
create table log (
execdate datetime not null,
toolid int not null
)
Any help is very appreciated!
Thanx!
Alexey
Well, looks clear to me, that the Odbc driver you are using does
not implement the ability to bind parameters in a query.
Use a "real" Jdbc driver (type 3 or type 4). There is a list
on www.mindprod.com
Davide
You probably ment http://mindprod.com or more specifically
http://mindprod.com/jdbc.html#JDBCLIST.
Petr
that's too easy.... ;p
Davide
> Well, looks clear to me, that the Odbc driver you are using does
> not implement the ability to bind parameters in a query.
> Use a "real" Jdbc driver (type 3 or type 4). There is a list
> on www.mindprod.com
I've changed java.sql.Date to java.sql.Timestamp. All became OK. My ODBC
driver has the ability to bind params
Try ps.setTimestamp(1, new java.sql.Timestamp(...
--
Lee Fesperman, FFE Software, Inc. (http://www.firstsql.com)
===================================================================
* Check out Database Debunkings (http://www.firstsql.com/dbdebunk/)
* "The Forum Where Database Matters Are Set Straight"
"Lee Fesperman" <firs...@ix.netcom.com> wrote in message
news:3B567D...@ix.netcom.com...
What happens if you use java.sql.Timestamp instead of java.sql.Date? I
would suspect that Timestamp maps to "datetime" better than Date. Just
a guess... I've never used the JDBC/ODBC bridge.