• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem in inserting "timestamp" in MS SQL server  RSS feed

 
Prem Subudhi
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have a table column whose datatype is "timestamp",As i run below code.it throws a exception as below
Exception in thread "main" java.sql.SQLException: [Microsoft][ODBC SQL Server Driver]Optional feature not implemented
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6998)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7155)
at sun.jdbc.odbc.JdbcOdbc.SQLBindInParameterDate(JdbcOdbc.java:841)
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.setDate(JdbcOdbcPreparedStatement.java:856)
at SampleDatetimestamp.main(SampleDatetimestamp.java:33)



import java.*;
import java.sql.*;
import java.util.*;
import java.text.*;
import java.io.*;
import java.awt.Image;
public class SampleDatetimestamp
{
public static void main(String[] args) throws Exception {
// Load the SQL Server 2000 Driver for JDBC. Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
// Connect to SQL Server.
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
Connection conn = null;//DriverManager.getConnection(url, "<UserId>", "<PassWd>");
conn = java.sql.DriverManager.getConnection("jdbc dbc:test", "sa","sa");
String command = "INSERT INTO TableNText(yob) VALUES(?)";
PreparedStatement ps = conn.prepareStatement(command, ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
Timestamp endDatetimestamp =new Timestamp(10000l);
ps = conn.prepareStatement(command);
ps.setTimestamp(1,endDatetimestamp);
ps.executeUpdate();
ps.close();
ps=null;
conn.close();
conn=null; javaranch
}
}
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Optional feature not implemented

Looks like the Driver you are using doesn't support this. Try using a different driver, such as jTDS.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!