PreparedStatement & ODBC

Does the JDBC-ODBC bridge driver support PreparedStatement INSERTS and UPDATES? I've been getting the following error:
"java.sql.SQLException: [Microsoft][ODBC SQL Server Driver]Optional feature not implemented"
Is this associated with the driver or a query statement structure problem?
Thanks
Tom B.

Does the JDBC-ODBC bridge driver support
PreparedStatement INSERTS and UPDATES?Yes, it does. I have used them.
"java.sql.SQLException: [Microsoft][ODBC SQL Server
Driver]Optional feature not implemented"
Is this associated with the driver or a query
statement structure problem?It is associated with whatever line of code threw the exception, probably. Hard to say with the information given.

Similar Messages

  • JDBC-ODBC and PreparedStatement.addBatch?

    Hi
    I am using the driver "sun.jdbc.odbc.JdbcOdbcDriver". I want to use preparedStatement and addBatch, but I get the error message:
    java.sql.SQLException: Driver does not support this function
         at sun.jdbc.odbc.JdbcOdbcPreparedStatement.addBatch(Unknown Source)Are the any way to come around this or do i have to execute one SQL-command a time?

    suladna wrote:
    I'm using MySQL Connector/J version 5.1.6 as JDBC. Huh?
    No you are not.
    Connector/J is a type 4 jdbc driver. And it most definitely is not the driver that you are using in the exception that you printed.
    If you have Connector/J then the problem is that you are loading the wrong driver and using the wrong connection string.

  • Query update on each iteration problem (MS SQL Sever / ODBC / Native Driver

    Hello,
    I�ve been working to learn some Java and now JDBC over the past 10 or so months.
    I think I have a general understanding of how to perform queries and work with data using JDBC. However, I�ve run into a problem. I�m trying to do a query of a set of data in a database based on the value of a status column. I want to loop over the messages and perform various functions with the data then update their status in the database. It�s preferable to do these 250 to 1000 rows at a time, but no more and no less.
    I�m connecting to MS SQL Server 2000, currently with ODBC. I�ve also tried it with the Java SQL Server 2000 drivers provided by Microsoft with the same results.
    I�ve found that I can do a one table query and loop though it with a while (rs.next()) {�} and run an Update statement with executeUpdate on each iteration without any problems, no matter the number of rows returned in query.
    I have not been able to use the updateString and updateRow inside the while loop. I keep getting errors like this at the line with the updateRow():
    Exception in thread "main" java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Row update failed.
    This occurs no mater how many rows I select, 1 or more.
    The real problem I�ve been having is that the query I need to loop though joins across several tables and returns some rows from some of those tables. This only seems to work when I query for 38 or less selected rows and I use an Update statement with executeUpdate on each iteration. The updateString and updateRow methods never work. Any number of rows selected greater than 38 causes a deadlock where the Update is waiting for the select to compete on the server and the Update can�t proceed until the Select is complete.
    As I stated above I�ve tried both ODBC and the native SQL Server driver with the same results. I have not tried any other databases, but that�s moot as my data is already in MS SQL.
    Questions:
    How can I avoid or get around this 38 row limit without selecting each row, one at a time?
    What am I doing wrong with the updateString and updateRow?
    Is there a better approach that anyone can suggest?
    Here�s some sample code with the problem:
    import java.sql.*;
    public class db1{
         public static void main(String[] args) throws Exception{
              Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              String url = "jdbc:odbc:eBrochure_live";
              Connection con = DriverManager.getConnection(url, "sa", "d3v3l0p");
              Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
              Connection con = DriverManager.getConnection("jdbc:microsoft:sqlserver://dcm613u2\\dcm613u2_dev:1433", "sa", "d3v3l0p");
              Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
              Statement stmt2 = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
              stmt.executeUpdate("USE [myDatabase]");
              stmt2.executeUpdate("USE [myDatabase]");
              String qGetMessages = "SELECT TOP 250 t1.messageUUID, t1.subjectHeader, t2.emailAddress as toAddress " +
              "FROM APP_Messages as t1 JOIN APP_addressBook_contacts as t2 " +
              "     On t1.toContactID = t2.contactID " +
              "WHERE t1.statusID = 'queued'";
              ResultSet rs = stmt.executeQuery(qGetMessages);
              while (rs.next()) {
                   String messageUUID = rs.getString("messageUUID");
                   String subjectHeader = rs.getString("subjectHeader");
                   System.out.println(messageUUID + " " + subjectHeader);
                   String updateString = "UPDATE APP_Messages " +
                        "SET statusID = 'sent' " +
                        "WHERE messageUUID = '" + messageUUID + "' ";
                   stmt2.executeUpdate(updateString);
              con.close();
    Thanks for the help,
    Doug Hughes

    // sorry, ps.close() should be outside of if condition
    String sql = "UPDATE APP_Messages SET statusID = 'sent' WHERE messageUUID = ?";
    Statement statement = con.createStatement();
    PreparedStatement ps = con.prepareStatement(sql);
    ResultSet rs = statement.executeQuery("your select SQL");
    if ( rs.next() )
    ps.clearParameters();
    ps.setString(1, rs.getString("your column name"));
    ps.executeUpdate();
    ps.close();
    rs.close();
    statement.close();

  • PreparedStatement.executeBatch() Not Working

    Hello,
    I'm having a problem with the executeBatch() command. It seems that whenever I used it, my program just hangs up. What this program do is that it first read a text file and place it in an Array. Then it would also read the Database and place the contenent of the table in an array as well. Each Array has at least 100,000 records. If the record from the textfile and the database matches, it would update the table using a preparedStatement.addBatch() command. After the said loop, it is then that the int[] cnt = preparedStatement.executeBatch() command is called. and that is when the Hanging part begins. Can you help me.
    Thanks.

    Hello,
    Yes, i'm using a JDBC-ODBC bridge. The dirver is (sun.jdbc.odbc.jdbcodbcdriver). I tried examining the program patiently waited, and eventually it did not hang anymore. At first instance, I did gave the program some time and look if it really hangs, but after 15-30 mins, it work but the the second executeBatch() didn't work. There were no errors or exception that were caught.
    Thanks.
    Hi,
    What driver are you using? And are you using the JDBC
    - ODBC bridge? Please post the exact error message you
    are getting when you try to do executeBatch().
    Nish

  • [Microsoft][ODBC Microsoft Access Driver] Syntax error

    I am new to Java. I have tried to write a simple program insert table in Access2002. However, I got the following error,
    ERROR: [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement
    My code is as follows,
    import java.lang.*;
    import java.sql.*;
    import java.util.*;
    import java.text.*;
    public class dateconv3 {
    public static void main (String[] args) {
    //Setting up the JDBC-ODBC bridge connection
    String DRIVER_NAME = "sun.jdbc.odbc.JdbcOdbcDriver";
    String CONNECTION_URL = "jdbc:odbc:book1";
    // The JDBC Connection Object
    Connection con = null;
    // The JDBC PreparedStatement object
    PreparedStatement ps = null;
    boolean rc = false;
    try { // try under for loop
    // Get an connection
    Class.forName(DRIVER_NAME).newInstance();
    con = DriverManager.getConnection(CONNECTION_URL);
    SimpleDateFormat formatter = new SimpleDateFormat ("yyyy/mm/dd");
    java.util.Date currentTime_1 = new java.util.Date();
    String dateString = formatter.format(currentTime_1);
    ParsePosition pos = new ParsePosition(0);
    java.util.Date currentTime_2 = formatter.parse(dateString, pos);
    java.sql.Date dCurDate=new java.sql.Date(currentTime_2.getTime());
    System.out.println(dCurDate);
    String userid = "1";
    String booktitle = "Java Servlet Programming";
    int amount = 202;
    String sqltxt="INSERT INTO TRANSLOG ( userid, booktitle, date, amount ) VALUES (?,?,?,?)";
    // Create a statement object that we can execute queries with
    ps = con.prepareStatement(sqltxt);
    ps.setString(1, userid);
    ps.setString(2, booktitle);
    System.out.println(currentTime_2);
    java.sql.Date sqlDate = new java.sql.Date(currentTime_2.getTime());
    System.out.println(sqlDate);
    ps.setDate(3, sqlDate);
    ps.setInt(4, amount);
    System.out.println("INSERT into translog table");
    // Execute the statement
    ps.execute();
    rc = true;
    } catch (Exception ex) {
    // Sent the error
    System.out.println("ex.getMessage() print: " + ex.getMessage());
    } finally {
    try {
    if (ps != null) {
    ps.close();
    if (con != null) {
    // Put the connection back into the pool
    con.close();
    } catch (Exception ex) {
    // Ignore any error here
    The Access has been set to the date format yyyy/mm/dd and I got the following result.
    java dateconv3
    2001-01-04
    Thu Jan 04 00:56:00 CST 2001
    2001-01-04
    INSERT into translog table
    ex.getMessage() print: [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement
    Please advise. I got frustrated with such a silly question. Anybody can help me to resolve it.
    Patrick

    INSERT INTO TRANSLOG ( userid, booktitle, date, amount ) VALUES (?,?,?,?)I don't have Access on my computer at home here, but it is quite possible that "date" is a reserved word in Access's version of SQL. If you can change the column name, I'd recommend you do that. Otherwise try changing your SQL code to this:
    INSERT INTO TRANSLOG ( userid, booktitle, [date], amount ) VALUES (?,?,?,?)
    But be warned that this [trick] doesn't work with other databases.

  • JDBC-ODBC Bridge Performance To MS Access

    Hey all, I'm running a Java app that extracts an entire table (set of tables) from Oracle and copies them into Access. The easiest implementation has been to use a DSN-less Type 1 JDBC-ODBC bridge connection to Access, but unfortunately the inserts are taking too long.
    I have tried both Statement and PreparedStatement approaches, with both single row and batch updates. Some of the performance times, relative to the computer I am on (PIII 1 gHz with 256 RAM), are as follows:
    Via Batch, about 8min, 15 seconds per 10,000 rows.
    Via Single Row updates/inserts, about 52 minutes for 45,000 rows.
    I've tried alot of varieties with batch, but 10,000 seemed to be the best. The largest table is only 45,000 rows (right now), but has the potential to grow much larger (obviously). This application needs to backup 4 databases, each with N tables (current N=7, but will expand). I'm trying to knock down the times and increase performance, but am not sure what is "reasonable" for Type 1 connections with JDBC. I've seen third party drivers, Type 3, for Access...but don't want to run the middle tier server for filtering request through. I'd rather use Type 4, but can't seem to find any for Access.
    Any suggestions? Recommendations? Let me know! Thanks all! :)

    Hi,
    If its a backup/batch process why are you worrying about performance, its only an offline process :) even if has to be triggered during an OLTP run this task asynchronously.
    I dont know why you have chosen java to do this ??? any way prepared statements with non scrollable resultsets will increase you performance better tha scrollable normal statements.
    Rajesh

  • Cannot resolve symbol : class odbc ERROR

    Hi Helper
    I am trying to compile a the following and I am getting the error
    C:\jdk\websiter>javac MainServlet.java
    MainServlet.java:86: cannot resolve symbol
    symbol : class odbc
    location: package jdbc
    Class.forName(sun.jdbc.odbc.JdbcOdbcDriver);
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    import java.io.*;
    import java.util.*;
    * This is the servlet to send the user the names of all the sites present in the database
    public class MainServlet extends HttpServlet implements ServletConstants
    Connection m_con;
    PreparedStatement m_pstmt;
    ResultSet m_res;
    Vector m_vecsiteName;
    public void Init(ServletConfig config) throws ServletException {
         super.init(config);
    }// end of init()
    public void service(HttpServletRequest req, HttpServletResponse resp)
    throws ServletException, IOException {
              m_vecsiteName = new Vector();
         try {
         Class.forName(sun.jdbc.odbc.JdbcOdbcDriver);
    m_con = DriverManager.getConnection("jdbc:odbc:sitewd", "", "");
    How can i fix it? thanks
    VT

    Replace the Statement
    Class.forName(sun.jdbc.odbc.JdbcOdbcDriver);
    as
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

  • PreparedStatements and MySQL Connector/J

    Hi All,
    I was wondering what is the exact SQL statement that is passed to MySQL server when we use PreparedStatements. I was trying using MySQL Connector/J, type4 driver. I tried with a simple servlet
        public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException   {
            response.setContentType("text/html");
            PrintWriter out = response.getWriter();
            out.println("<html>");
            out.println("<body>");
            out.println("<head>");
              try {
                   Class.forName("com.mysql.jdbc.Driver");
                   Connection con=DriverManager.getConnection("jdbc:mysql://localhost/mydb?user=root","root","");
                   //Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                   //Connection con=DriverManager.getConnection("jdbc:odbc:test");
                   PreparedStatement pst=con.prepareStatement("select * from AS_ITM where ID_ITM=?");
                   out.println("PreparedStatement = "+pst);
                   out.println("<br>");
                   pst.setString(1, "10");
                   out.println("PreparedStatement = "+pst);
                   //ResultSet rs=pst.executeQuery();
                   con.close();
              }catch(Exception e){
                   out.println(e);
            out.println("</head>");
            out.println("<body>");
            out.println("</body>");
            out.println("</html>");
    Here I am printing PreparedStatement  object's generated SQL twice and not even executing the query.
    And the result is:
    PreparedStatement = com.mysql.jdbc.PreparedStatement@19f3736: select * from AS_ITM where ID_ITM=** NOT SPECIFIED **
    PreparedStatement = com.mysql.jdbc.PreparedStatement@19f3736: select * from AS_ITM where ID_ITM='10'
    See second statement? I have not even sent it to the server.
    So is this jdbc driver preparing a simple Statement before it is sent to MySQL server?
    Is it what a jdbc driver is supposed to do? So then whats the use of PreparedStatement?Thanks,
    Kishor

    Hi,
    Just exactly what a JDBC driver is supposed to do with a PreparedStatement is not specified in JDBC I believe. I think they only requirement is that a PreparedStatement should be able to insert the various data types correctly into an SQL string.
    I am fully aware that PreparedStatements should also be able to give a better performance, for instance by only sending the parameters when you use it the second time, and not the whole the SQL. But I think this is up to the database and driver implementation to decide whether to do this, and how.
    Remember, the JDBC driver may be sending other information across to the database than the SQL. We can't see that from looking at the PreparedStatement only. You would have to use a network packet sniffer to see all data exchanged between the driver and the database
    -Jakob Jenkov

  • Microsoft][ODBC SQL Server Driver]Optional feature not implemented

    this is my program code for java jdbc:odbc SQL connectivity
    but iam getting the error as
    *java.sql.SQLException: [Microsoft][ODBC SQL Server Driver]Optional feature not implemented*
    package desktopapplication2;
    import java.sql.*;
    * @author Bharat Raj Verma
    public class db {
        void get(String gr,String fn,String ln,String job ,Integer rate,Integer ot,String att,long amt,String cmt)
          try
             Connection con=null,con1=null;
            Statement stmt2;
            String query = "Update dbo.attend SET Gr = ? , fn = ? ,ln = ?, job = ? , rate = ? , ot = ? , att = ? ,amt = ? , comment = ?";
           // String query1 = "Select accnum rom dbo.newacc where accnum= ?";
            String url = "jdbc:odbc:bharat";
          Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            con = DriverManager.getConnection(url,"","");
            con1 = DriverManager.getConnection(url,"","");
            System.out.println("connection Established");
            stmt2 = con.createStatement();
            Statement stmt = con1.createStatement();
            ResultSet rs;
            rs=stmt.executeQuery("select * from dbo.attend");
            while(rs.next())
                String cmp1= rs.getString("gr");
                if(cmp1.equalsIgnoreCase(gr))
                        PreparedStatement ps1 = con.prepareStatement(query);
                        System.out.println("Insisde RS");
                        ps1.setString(1,gr);
                        ps1.setString(2,fn);
                        ps1.setString(3,ln);
                        ps1.setString(4,job);
                        ps1.setInt(5,rate);
                        ps1.setInt(6,ot);
                        ps1.setString(7,att);
                        ps1.setLong(8,amt);
                        ps1.setString(9,cmt);
                        System.out.println("SSS");
                      //  ps1.setString(1,gr);
                        ps1.executeUpdate();
                       System.out.println("Success");
          catch(Exception e1)
              System.err.println(e1);
    }This is the SQL table in which iam trying to insert the value
    SET ANSI_PADDING OFF
    create table attend
    Gr VARCHAR(20) primary key,
    fn VARCHAR (25),
    ln VARCHAR(25),
    job VARCHAR(25),
    rate integer,
    ot integer,
    att varchar(10),
    amt varchar (10),
    comment varchar(70)
    )the complete output is
    init:
    deps-jar:
    Compiling 1 source file to C:\Documents and Settings\Bharat Raj Verma\My Documents\NetBeansProjects\DesktopApplication2\build\classes
    compile:
    run:
    connection Established
    Insisde RS
    java.sql.SQLException: [Microsoft][ODBC SQL Server Driver]Optional feature not implemented
    BUILD SUCCESSFUL (total time: 29 seconds)
    here is the stack trace
    java.sql.SQLException: [Microsoft][ODBC SQL Server Driver]Optional feature not implemented
    at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6958)
    at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7115)
    at sun.jdbc.odbc.JdbcOdbc.SQLBindInParameterBigint(JdbcOdbc.java:1225)
    at sun.jdbc.odbc.JdbcOdbcPreparedStatement.setLong(JdbcOdbcPreparedStatement.java:592)
    at desktopapplication2.db.get(db.java:47)
    at desktopapplication2.DesktopApplication2View.jButton1ActionPerformed(DesktopApplication2View.java:394)
    at desktopapplication2.DesktopApplication2View.access$800(DesktopApplication2View.java:22)
    at desktopapplication2.DesktopApplication2View$4.actionPerformed(DesktopApplication2View.java:183)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1849)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2169)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
    at java.awt.Component.processMouseEvent(Component.java:5517)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3135)
    at java.awt.Component.processEvent(Component.java:5282)
    at java.awt.Container.processEvent(Container.java:1966)
    at java.awt.Component.dispatchEventImpl(Component.java:3984)
    at java.awt.Container.dispatchEventImpl(Container.java:2024)
    at java.awt.Component.dispatchEvent(Component.java:3819)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
    at java.awt.Container.dispatchEventImpl(Container.java:2010)
    at java.awt.Window.dispatchEventImpl(Window.java:1791)
    at java.awt.Component.dispatchEvent(Component.java:3819)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
    Plz can anyone help ???

    and what was the solution?
    thanks in advance
    brindy

  • PreparedStatement and executeBatch()

    Hi,
    I am trying to insert records into the database using the addBatch() and executeBatch() methods. I am using PreparedStatement. And I am trying to insert 52 records at a time.
    I have the records in an array, and I am looping through the array, setting the parameters for the prepared statement and doing addBatch(). And finally when I come out of the loop I call preparedStatement.executeBatch().
    int[] updateCounts = ps.executeBatch();
    Here it is throwing out the ArrayIndexOutOfBoundsException. Anybody has any idea why this is happening? This works fine with the Statement object, but it is with the PreparedStatement that I am having this problem. I am using JDK 1.3. My database is DB2 UDB 7.1 and my driver is IBM DB2 ODBC Driver.
    thanks in advance,
    Nish

    Hi,
    Thanks for the reply... Here is my code.
    public void insertNetFcst(Connection con, PreparedStatement ps, NetForecast[] arrNF){
    Connection conn = con;
    PreparedStatement psIns = ps;
    NetForecast[] arrNet = new NetForecast[52]; //Array of objects of type NetForecast
    arrNet = arrNF;
    int intLen = 0;
    intLen = arrNet.length;
    try{                    
    for (int ins = 0; ins < intLen; ins++){
    NetForecast nFct = new NetForecast();
    nFct = (NetForecast)arrNet[ins];
    psIns.setString(1, nFct.getCorpId());
    psIns.setString(2, nFct.getDivId());
    psIns.setString(3, nFct.getShipWhseId());
    psIns.setString(4, nFct.getRecvWhseId());
    psIns.setDouble(5, nFct.getUpcId());
    psIns.setInt(6, nFct.getYearId());
    psIns.setInt(7, nFct.getWeekNbr());
    psIns.setInt(8, nFct.getDemandQty());
    psIns.setString(9, nFct.getUomCode());
    psIns.setInt(10, nFct.getReqdYear());
    psIns.setInt(11, nFct.getReqdWeek());
    psIns.setString(12, nFct.getFcstTypeInd());
    psIns.setTimestamp(13, new Timestamp(System.currentTimeMillis()));
    psIns.addBatch();
    int[] updateCounts = psIns.executeBatch();
    //I am getting the exception at this line... where I call executeBatch()
    conn.commit();
    catch(BatchUpdateException b){
    System.err.println("SQLException: " + b.getMessage());
    System.err.println("SQLState: " + b.getSQLState());
    System.err.println("Message: " + b.getMessage());
    System.err.println("Vendor: " + b.getErrorCode());
    System.err.print("Update counts: ");
    int [] updateCounts = b.getUpdateCounts();
    for (int i = 0; i < updateCounts.length; i++) {
    System.err.print(updateCounts[i] + " ");
    b.printStackTrace();
    catch(SQLException insExp){
    System.out.println("Duplicate record exception..." + insExp);
    thanks,
    Nish

  • Help needed, Oracle and PreparedStatement setNull for VARCHAR problem

    Using the JDBC drivers included with JDK 1.3, I am encountering a strange problem when trying use a PreparedStatement with a NULL parameter in a VARCHAR column. When running the code below (user_id is an integer and login is a nullable varchar) the program will simply wait and wait and wait.
    import java.sql.*;
    public class OracleNullTest {
         public static void main(String [] args) {
              try {
              String odbcName = args[0];
              String dbUserName = args[1];
              String dbPassword = args[2];
              int id = Integer.parseInt(args[3]);
              Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              Connection con = DriverManager.getConnection("jdbc:odbc:"+odbcName, dbUserName, dbPassword);
              PreparedStatement ps = con.prepareStatement("Insert into junk(user_id, login) values(?,?)");
              ps.setInt(1,id);
              ps.setNull(2,Types.VARCHAR);
              ps.executeUpdate();
              ps.close();
              con.close();
              } catch (Exception e) { e.printStackTrace(); }
    If I change the 'ps.setNull(...)' to 'ps.setString(2,"test")' things work fine. Furthermore, I've changed the VARCHAR column to a TIMESTAMP and setting it to null works fine. The above code works fine on DB2 and SQL Server so only Oracle is anatagonizing me.
    Any insight or help is greatly appreciated.

    The ODBC driver has nothing to do with java. What you are using in java is a JDBC driver.
    Various microsoft products install a ODBC Oracle driver. Oracle also provides a driver that is installed with the Oracle Client install.
    I have seen reports that suggest the MS driver as good as the Oracle driver, consequently that could be source of your problem.

  • [Oracle][ODBC][Ora]ORA-24801: illegal parameter value in OCI lob function

    Hi,
    I am trying to insert an xml doc into a column of Oracle table which has a datatype CLOB in JSP. PFB my code that I am using --
    int id = 100;
    String st1 = "NEW";
    String st2 = "WLR3_IN_1";
    Date dt = new SimpleDateFormat("mm/dd/yyyy").parse("04/02/2008");
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    con = DriverManager.getConnection("jdbc:odbc:CST Server","xmluser","xmluser");
    String query = "INSERT INTO SEQ_API_MESSAGE_IN(SEQ_NO,MESSAGE_TEXT,STATUS,DIALECT,CREATED_TS) VALUES(?,?,?,?,?)";
    out.println(6);
    String fn = "C:/order.xml";
    out.println(7);
    PreparedStatement stmt = con.prepareStatement(query);
    out.println(8);
    File file = new File(fn);
    out.println(9);
    FileReader inputFileReader = new FileReader(file);
    stmt.setInt(1,id);
    stmt.setCharacterStream(2,inputFileReader, (long)file.length());
    stmt.setString(3,st1);
    stmt.setString(4,st2);
    stmt.setDate(5,new java.sql.Date(dt.getTime()));
    out.println(10);
    if (stmt.executeUpdate() != 1) {
    System.out.println("No record inserted.");
    But I am getting an output in the form of an Oracle error - 5 6 7 8 9 10 [Oracle][ODBC][Ora]ORA-24801: illegal parameter value in OCI lob function
    So all the statements are getting executed after which this Oracle error is thrown. Could you help me with this.
    Thanks in anticipation.. :)

    As suggested I may try switching to JDBC instead of JDBC-ODBC bridge driver , but I also tried doing this to get the sysdate --
    //Date dt = new SimpleDateFormat("mm/dd/yyyy").parse("04/02/2008");
    String date = DateFormat.getInstance().format(new Date());
    stmt.setString(5,date);
    and now I am getting this error -- 5 6 7 8 9 10 [Oracle][ODBC][Ora]ORA-01843: not a valid month Hello1
    Hello1 is coming from --
    catch (SQLException sqle){
    out.println(sqle.getMessage());
    out.print("Hello1");
    }

  • Hibernate Query vs PreparedStatement for SQL

    Hi,
    I am using Hibernate for DAO classes, which i am using for the basic CRUD operations. But for complex queries with complex joins i am writing the SQL.
    In such case whether it is better to use the Query.createSQLQuery(String sql) to invoke the SQL or better to use the PreparedStatement since i am invoking only the SQL as supposed to HQL by getting the connection from the Hibernate Session. Since the PreparedStatement is precompiled it may be faster than invoking the SQL through the Query.createSQLQuery(String sql)? or using the Session.getNamedQuery(QUERY_NAME)? Please let me know your opinion on this.
    Thanks

    Whether you use Hibernate, ODBC, BDE, or Funky Foo's SQL client library, Oracle does not give a damn.
    It receives a statement from the client. This can either be SQL or an anonymous PL/SQL block. It parses it as a cursor. It then provides the client with a cursor handle to reference the cursor.
    The cursor is essentially a program. If it has bind variables, it is a program that accepts parameter input. This allows the very same program to be executed multiple times with different input parameters. For example, executing the same INSERT SQL cursor for different values and inserting multiple rows using the very same cursor.
    A cursor can also (like a program), produce output. An example is a SELECT cursor - where the fetch interface of the cursor enables the caller to consume the output of the cursor.
    So what is optimal in this respect? First and foremost cursors that are created using and used with bind variables. Secondly, re-using the very same client cursor handle (and not just the same server side SQL cursor) where possible (e.g. like repeating the same SQL INSERT statement with different values).
    The question to asked is whether the method you select to use on the client side - be that Hibernate or Funky Foo SQL, support this?
    The consideration to make is the following. Why code SQL in the client side? SQL is executed on the server-side - refers to server side data structures and needs to be tuned on the server. Put that code in a client and it significantly increases the complexity and decrease the flexibility of SQL.
    The alternative (and recommended approach) is to use PL/SQL to encapsulate all SQL. Instead of the client (and client programmer) needing to know SQL, a PL/SQL call interface is provided with calls like GetInvoice() to return a single specific invoice, or GetInvoiceByDate() that returns selected invoices for a date range. The PL/SQL code creates the SQL cursor and returns the client cursor handle as a reference cursor to the caller.
    This also allows business and validation logic to be implemented in the PL/SQL call interface to protect data integrity and business transaction sanity. A database structure change requires the SQL inside a PL/SQL procedure to be changed - without having to touch the client code. Likewise, SQL can be tuned and improved without having recompile a single byte of client code. And the same PL/SQL call interface services all clients - unlike multiple Java clients duplicating the same SQL (and not always correctly) to do the same thing, or having to duplicate and repeat the same data validation and business rule logic.

  • Java JDBC-ODBC GROUP BY (aggregate function) error

    I get the error
    "java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] You tried to execute a query that does not include the specified expression 'CUSTOMER_ID' as part of an aggregate function."
    when I try to execute the following query:
    PreparedStatement stmt = connection.prepareStatement(
    "SELECT Customers.customer_id, Customers.customer_name, SUM(Transactions.surcharge) AS surcharge, SUM(Transactions.interchange) AS interchange, SUM(Transactions.approved) AS transactions " +
    "FROM (Customers INNER JOIN Terminals ON Customers.customer_id = Terminals.customer_id) " +
    "INNER JOIN Transactions ON Terminals.terminal_id = Transactions.terminal_id " +
    "WHERE Transactions.transaction_date=#12/8/2003# " +
    "GROUP BY Customers.customer_id, Customers.customer_name",
    ResultSet.TYPE_SCROLL_INSENSITIVE,
    ResultSet.CONCUR_READ_ONLY
    Funny thing is this query works fine when I execute it in Microsoft Access directly. I can't figure out what's causing the problem. Any help?

    Have you tried:
    PreparedStatement stmt = connection.prepareStatement(
    "SELECT Customers.customer_id, Customers.customer_name, SUM(Transactions.surcharge) AS surcharge, SUM(Transactions.interchange) AS interchange, SUM(Transactions.approved) AS transactions " +
    "FROM (Customers INNER JOIN Terminals ON Customers.customer_id = Terminals.customer_id) " +
    "INNER JOIN Transactions ON Terminals.terminal_id = Transactions.terminal_id " +
    "WHERE Transactions.transaction_date=#12/8/2003# " +
    "GROUP BY customer_id, customer_name",
    ResultSet.TYPE_SCROLL_INSENSITIVE,
    ResultSet.CONCUR_READ_ONLY
    (Who knows ?... Sometimes SQL engines are very strangely built!)

  • [Microsoft][ODBC Microsoft Access Driver] COUNT field incorrect

    Hello togehter!
    I get the following error when I try to execute a insert statment in a table:
    [Microsoft][ODBC Microsoft Access Driver] COUNT field incorrect
    I have a table with PictureID (Autowert), Path and Diagnostic (Strings)
    My preparedStatement is:
    INSERT INTO Pictures (Path, Diagnostic) VALUES (?,?)
    Any ideas??

    private static int addPicture(String path, String diagnostic)throws SQLException
              PreparedStatement statement = DataBase.getConnection().prepareStatement("INSERT INTO Pictures (Path, Diagnostic)" +
                   "VALUES (?,?)");
              statement.setString(1,path);
              statement.setString(1,diagnostic);
              statement.executeUpdate();
              statement.close();
    this is the part of my method that is nor working.
    Thanks for your help.

Maybe you are looking for

  • Poor reflective memory read performanc​e

    I'm having some trouble with the GE 5565 PIORC reflective memory set of VIs for use with our reflective memory setup. I need to copy a pretty sizable chunk of memory out of reflective memory and into a DLL I've written, but the performance on the "GE

  • Report Builder 3.0 launch issue in SharePoint Integration mode

    Hello, I'm facing issue when opening the report builder 3.0 tool. Report server is configured in SharePoint Integration mode. I already have the FQDN configured for report server and in SharePoint (AAM) but still it fails when the end user is trying

  • How do i customize the states in a vertical menu bar?

    i see that it is possible to change the states for a horizontal venu bar, but i can't get it to work for the vertical one.  please tell me we can edit the states in a vertical menu bar. valerie

  • Problem with HP Photosmart C4480

    I've just recently bought a Photosmart C4480.  I replaced the ink cartridge with the 99 photo cartridge, which fill the right side and  which means that there is only one ink cartridge inside my printer. I try to print a photo but realised it came ou

  • Get a Column value based on other column value in a single query

    Hi All, I have a problem here - In Table XYZ I have columns by name A, B, C and COL_I. COL_I has a value A or B or C. Based on the value in COL_I, I need to get the value from the corresponding column in the table. For Ex: If the COL_I has the value