File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Problem in inserting Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Problem in inserting "timestamp" in MS SQL server" Watch "Problem in inserting "timestamp" in MS SQL server" New topic
Author

Problem in inserting "timestamp" in MS SQL server

Prem Subudhi
Greenhorn

Joined: Feb 22, 2006
Posts: 1
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

Joined: Apr 14, 2004
Posts: 10336


Optional feature not implemented

Looks like the Driver you are using doesn't support this. Try using a different driver, such as jTDS.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem in inserting "timestamp" in MS SQL server
 
Similar Threads
Why this OverFlow error during updating?
connecting to Webtrends reporting DB using JDBC-ODBC
Connection with database Help
Problems in inserting data to MS Access Database
JDBC with MS SQL 2000