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.

Similar Messages

  • Newbie: Problem with jdbc-odbc and MS SQL server 2005

    I'm on win vistax64 with SQLSERVER 2005 and I have set up the odbc source as system dsn using the SQL Native Client driver with SQL authentication and the connectivity test in the end succeeds.
    I'm trying to make a simple web app that will connect to the database and perform simple querries. It's a school assignment.
    I'm using the jdbc-odbc bridge because it's the simplest way to do it and it's what we were shown in class.
    I get the following irritating error:
    "Cannot establish a connection to jdbc:odb:sstmdb using sun.jdbc.odbc.JdbcOdbcDriver ([Microsoft][ODBC Driver Manager] Data source name not found and no default driver specifies)".
    I'm working with netbeans 5.5.1 and this error is what I get when in the runtime tab I try to connect with the jdbc-odbc. I get a similar error in the logs when I try to run the app on the j2ee server.
    This is the java class that establishes the connection.
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    public class Connector {
        private static final String dbUrl="jdbc:odbc:sstmdb";
        private static final String user="kimon";
        private static final String password="jackohara";
        public static Connection getConnection(){
            Connection conn = null;
            try {
                Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                conn = DriverManager.getConnection(dbUrl,user,password);
            } catch (SQLException e) {
                e.printStackTrace(); 
            } catch (ClassNotFoundException e) {
                e.printStackTrace(); 
            return conn;
    }It has worked perfectly on my school PC with winXP and MSDE2000.
    What am I missing?

    Ok, help came from an other way where I was inquiring about a different problem:
    Connectivity works fine by using User DSN instead of System DSN for the ODBC source.

  • Cannot access remote FoxPro dbf file using jdbc-odbc and system DSN

    Hi all,
    I have a foxpro database sitting on remote server (netware server). the dbf folder is shared and I can access it using windows explore on my weblogic server (windows 2003). I created a system dsn for that. I can access the database from the a stand alone java program using
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection surgConn = DriverManager.getConnection("jdbc:odbc:FoxDB", " ", " ");
    But when I use the same thing in my weblogic 8.1 application, I cannot access the database. I didn't config any data source in weblogic 8.1
    Why?
    When I try this on my own computer - windows 2000, weblogic 8.1 workshop. remote foxpro database dbf folder. it works.
    Any idea?
    Thanks very much

    Laura Ren wrote:
    Hi all,
    I have a foxpro database sitting on remote server (netware server). the dbf folder is shared and I can access it using windows explore on my weblogic server (windows 2003). I created a system dsn for that. I can access the database from the a stand alone java program using
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection surgConn = DriverManager.getConnection("jdbc:odbc:FoxDB", " ", " ");
    But when I use the same thing in my weblogic 8.1 application, I cannot access the database.What exception do you get? WebLogic is just like any other Java App. That code
    should work OK (though I have a better way)... Be warned that the JDBC ODBC
    bridge is specifically dangerous. It is not threadsafe.
    Joe
    I didn't config any data source in weblogic 8.1
    Why?
    When I try this on my own computer - windows 2000, weblogic 8.1 workshop. remote foxpro database dbf folder. it works.
    Any idea?
    Thanks very much

  • Problem: connect DB with Applet by JDBC-ODBC bridge

    Dear all,
    When I connect local MS SQL server by "sun.jdbc.odbc.JdbcOdbcDriver" as below, it works well! However, when I put the similar code under Java Applet program, it cannot run by showing error:
    java.security.AccessControlException: access denied (java.lang.RuntimePermission accessClassInPackage.sun.jdbc.odbc)
    at java.security.AccessControlContext.checkPermission(AccessControlContext.java:272)
    at java.security.AccessController.checkPermission(AccessController.java:399)
    at java.lang.SecurityManager.checkPermission(SecurityManager.java:545)
    at java.lang.SecurityManager.checkPackageAccess(SecurityManager.java:1501)
    at sun.applet.AppletSecurity.checkPackageAccess(AppletSecurity.java:169)
    I think Java Applet has some security policy when I try to use applet to connect(read/write) DB. How can I solve it so that I can browse my applet under IE.
    Thanks a lot!
    Here is my worked code in Java program but not in Applet:
    import java.sql.*;
    public class TestJDBC1 {
    public static void main(String args[]) throws Exception {
    String userid = "";
    String password = "";
    // Register the driver with DriverManager
    new sun.jdbc.odbc.JdbcOdbcDriver();
    // Get a connection
    Connection conn = DriverManager.getConnection("jdbc:odbc:rdr",
    userid, password);
    // Create a statement for executing SQL
    Statement stmt = conn.createStatement();
    // Execute a query / SELECT statement
    ResultSet rset = stmt.executeQuery("SELECT * FROM PlatformNode");
    ResultSetMetaData rsmd = rset.getMetaData();
    // Find out how many columns were returned by the query
    int count = rsmd.getColumnCount();
    // Loop until all rows have been processed
    while (rset.next()) {
    // Loop until all columns in current row have been processed
    for (int i = 1; i <= count; i++) {
    // Print out the current value
    System.out.print(rset.getObject(i));
    // Put a comma between each value
    if (i < count) {
    System.out.println(",");
    // Start the next row's values on a new line
    System.out.println("");
    // Close the database objects
    rset.close();
    stmt.close();
    conn.close();

    Hi,
    Applets by default are restricted from accessing a lot of things.to enable applest from accessing database and other thngs u need to edit the policy file
    Try this.
    go to the jre/bin directory open the policytool.exe file
    and add permission(in ur case RuntimePermission to access class in package sun.jdbc.odbc) and save the file.
    this will enable applets from accessing the databse.
    Hope that helps
    Note:
    policytool.exe must be used to open the java.policy file present in /jre/lib/security directory and then add the permissions
    regards,
    Partha

  • " want to learn JDBC,ODBC,etc .."

    Hi All,
    This forum has been much help to me till now..
    Now that i am little confident with basic java, i want to learn accessing a database(oracle) using java for which i need some good tutorials which teach me JDBC,ODBC and stuff req for that..
    Can u suggest me some good sites/tutorials(free) which provides me with the above??
    And also what all is necessary/required for the developing environment?.
    (i have already searched google..but very confused as to which is really suitable for a beginner like me)
    Any help is appreciated
    Thanks and Regards,

    go to this site http://www.javaworld.com
    type in the search textbox tutorial jdbc
    You should find explanation enough to understand jdbc etc...

  • Limitations of Statement.addBatch() jdbc:odbc bridge to SQL Server 2K

    Hi all,
    I was attempting some performance tuning in my applications and I attempted to use the addBatch method in a statement during a loop and the corresponding executeBatch when the loop is complete. For some reason all my inserts were not sent to the database. So I did a test. I wrote some code that would allow me to create 'X' amount of sql statements and add them to batch and execute. Here's a sample of my code:
    void jButton7_actionPerformed(ActionEvent e)
    try
    if(connect == null)
    String url = "jdbc:odbc:someDataSourceName";
    Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
    connect =
    DriverManager.getConnection( url, "****", "****");
    System.out.println("Connection supports batch updates T/F = " + connect.getMetaData().supportsBatchUpdates());
    int x = new Integer(fldNumOfLoops.getText()).intValue();
    java.sql.Statement stat = connect.createStatement();
    stat.addBatch("create table stutemp (somecolumn varchar(200)); ");
    for(int i = 0; i < x; i++)
    stat.addBatch("insert into stutemp (somecolumn) values('This is a test of inserting row Number " + i + "'); ");
    java.sql.Timestamp tsNow = new java.sql.Timestamp(new java.util.Date().getTime());
    stat.executeBatch();
    System.out.println("Batching " + x + " rows started " + tsNow + " ended " + new java.sql.Timestamp(new java.util.Date().getTime()));
    stat.close();
    stat = null;
    stat = connect.createStatement();
    java.sql.ResultSet rs = stat.executeQuery("select count(*) from stutemp");
    while(rs.next())
    System.out.println("Results returned from sb batching = " + rs.getString(1));
    stat.close();
    stat = null;
    stat = connect.createStatement();
    stat.execute("drop table stutemp");
    connect.close();
    connect = null;
    catch(Exception ex)
    ex.printStackTrace();
    For some reason, I'm only safe inserting 455 records along with the table create. sometimes it will allow me to insert 456, or 457, but never any more than that. And it fluctuates. Does anyone know why this is? Is there a size limit on adding statements to batch? For giggles, I created a String Buffer version where I'm adding statements to a stringbuffer and doing an execute on the statement. I'm getting the same results.
    Thanks,
    Stu

    Sorry, One more thing. If I put a Thread.Sleep(); after the execute batch I get more inserts depending on the amount of time I tell my thread to sleep.........
    What's up with this. Shouldn't this be a Sync process where the calling thread should wait until the statement executes????????????????

  • MS access,servlets and jdbc-odbc

    when i try to connect to ms access database using servlet i get unable to open registry key DriverId problem.
    servlet successfully extracts the form data.Even jdbc code alone works fine, but when jdbc code is embeded in servlet I get the above error.I am using java web server 2.0 and a jdbc-odbc(type 1) driver.
    Please help me.................!
    I cannot proceed with my project without solving this problem.

    You have not specified the exception class.
    If it is java.security, try peeping into jws security directory, and set the access to your servlet directory.
    I do not know this helped you or not.
    regards

  • J2EE and JDBC-ODBC bridge driver

    Hi all,
    in my application I want to access an ODBC database to get the data and put it into cloudscape. In my resources.properties I added the jdbc driver
    jdbcDriver.1.name=sun.jdbc.odbc.JdbcOdbcDriverand also added a datasource
    jdbcDataSource.5.name=jdbc/MyOdbc
    jdbcDataSource.5.url=jdbc\:odbc\:odbc-nameAfter starting j2ee 1.3.1 the server reports following error:
    Error in creating data source object: jdbc/MyOdbcWhat's going wrong? Thanks for your help.
    -chris

    additional information:
    The phenomenon happens only if I use J2SDK 1.4.0. Running the 1.3.1 the driver is loaded without any problems.
    Is it a security issue or am I not allowed to use 1.4 because it's too new?
    -chris

  • JDBC-ODBC Bridge Drivers and Microsoft Access

    Are there any good tutorials on setting this up? Forgive me if there is one on this site - I couldn't find it. I just know (from some other sites) that it can be a pain to set up and get working right.

    I mean installing and configuring JDBC-ODBC to be
    able to connect to Access...I know about JDBC and
    it's API. I just need to know how to configure
    everything so that I can use the API.If you have a version of windows (at least back to 95) that doesn't have the MS Access ODBC driver and/or doesn't have the ODBC shell then something is wrong with your windows.

  • JDBC-ODBC Bridge and Lotus Notes

    Greetings
    Got this message in the Event Viewer when testing my ODBC
    connection to a Lotus Notes DB:
    Description:
    The description for Event ID ( 0 ) in Source ( ColdFusion 8
    ODBC Server ) cannot be found. The local computer may not have the
    necessary registry information or message DLL files to display
    messages from a remote computer. You may be able to use the
    /AUXSOURCE= flag to retrieve this description; see Help and Support
    for details. The following information is part of the event:
    ColdFusion 8 ODBC
    Server@LOCALHOST,ErrorCode=3004,ErrorMessage=sched.swschd.1424.Internal
    error, an unexpected exception was detected..
    The Notes DB is on another server. I have installed NotesSQL
    and created an ODBC data source in Windows. I created the data
    source in CF admin pointing to the Windows ODBC. When I tested the
    connection I got the message above. I can connect to the Notes DB
    using the Notes Client installed on the server with Coldfusion.
    Any thoughts?
    Thanks

    >
    It's not a CLASSPATH problem.
    Did you create an ODBC DSN named test?
    You have two choices:
    (1) Create an ODBC DSN named test, OR
    (2) Rewrite your database URL as:
    String url = "jdbc:odbc:DRIVER={Microsoft Access Driver (*.mdb)};DBQ=c:\\foo\\bar\\baz.mdb";
    Make the DBQ equal to the path to your Access database and it'll work.
    I prefer the second idiom, because it doesn't require setting up a DSN. - MOD
    Yes, I have created a DSN with the name 'test'.
    The second option "jdbc:odbc:DRIVER={Microsoft Access Driver (*.mdb)};DBQ=c:\\foo\\bar\\baz.mdb" -> is the part 'baz.mdb' the name of the my database. So it will be: "jdbc:odbc:DRIVER={Microsoft Access Driver (*.mdb)};DBQ=c:\\foo\\bar\\test.mdb";
    But what is the biggest different between those two? What is the advantage and the disadvantage?

  • JDBC/ODBC Bridge and getArray()

    I'm trying to use the getArray() method and I get the following:
    java.lang.UnsupportedOperationException
    I'm using the sun.jdbc.odbc.JdbcOdbcDriver
    Is there any other (free) bridge that allows you to use JDBC 2.0's getArray() method?
    Thanks,
    Michael

    I would look for a driver for the particular DBMS that you are using. Take a look here http://industry.java.sun.com/products/jdbc/drivers and here http://ourworld.compuserve.com/homepages/Ken_North/jdbcvend.htm
    Col

  • Applets and JDBC-ODBC Bridge

    I have the following error when i try to run my program(I have used JFrame instead of JApplet ) :
    [Microsoft] [ODBC Driver Manager] Invalid cursor state
    I'm using VJ# and i read on oreilly's site that JDBC-ODBC bridge doesn't work with it, so how should i resolve the problem?
    could somebody suggest a better and easy-to-use Type 1 driver(which is free)

    Closing the statements defeats the purpose of prepared statements with my design. The whole point is to load them at startup and reuse them.
    Another driver is an option however where does one get one and are they free?
    I have implemented a temporary solution that I found in the archives. I have used a while statement to make sure that I have got to the end of the result set, however a nested if only looks for the first result. I am only retrieving one row from the database so only need the first. Logic says to me that rs.next() must have to evaluate to false. It is a bit messy but it works . . . so far.
    L

  • Com.mysql.jdbc.driver and jdbc:odbc bridge driver

    Hi All,
    I want to update mysql database from data in hashtable. My application already uses JDBC:OBDC bridge driver for retrieving data from excel sheet and putting in hashtable.
    For connecting to mysql i need to use com.mysql.jdbc.driver too in the same code.
    How to do that?
    my code uses.
    Read(String strFilePath,String strFileName)
               filepath = strFilePath;
               filename = strFileName;
                strDriver= "jdbc:odbc:Driver={MicroSoft Excel Driver (*.xls)}";Thanks

    Please stay with one thread:
    http://forum.java.sun.com/thread.jspa?threadID=5145466&tstart=0
    Please don't cross-post this way.

  • Setting up and checking JDBC-ODBC bridge

    I'm supporting an application that does not use general JDBC drivers but relies on the JDBC-ODBC bridge. Can't currently get a connection to my 10.2 database, and it looks like the problem is that the JDBC-ODBC bridge isn't set up. Any hints on how to do this?
    (I originally posted this on the database forum but was told to try here. Odd since my app is HTML and XHTML, and was not developed using JDev).
    Regards
    Simon

    Why do you use the JDBC-ODBC bridge; if the database is Oracle 10? You should connect from Java to Oracle with the API driver or even better with the Oracle JDBC driver.
    If the client is not Java there should be no reason the use the bridge.
    The Sun JDBC-ODBC bridge is not intented for production.
    You can find configuration information in this document:
    http://java.sun.com/j2se/1.3/docs/guide/jdbc/getstart/bridge.doc.html
    Regards Flemming

  • Problem with Stored Procedure and inout parameter and jdbc-odbc bridge

    create or replace procedure test_proc( para in out number) as
    begin
    if para = 1 then
    para := 11111;
    else
    para := 22222;
    end if;
    end;
    public static void main(String args[]) throws Exception{
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    String url = "jdbc:odbc:test3";
    String uid = "scott";
    String pwd = "tiger";
    Connection conn = DriverManager.getConnection(url,uid,pwd);
    CallableStatement cstmt = conn.prepareCall("{call test_proc(?)}");
    cstmt.registerOutParameter(1,Types.INTEGER);
    cstmt.setInt(1,1);
    cstmt.execute();
    System.out.println("para = " + cstmt.getInt(1));
    cstmt.close();
    conn.close();
    I get the following errors:
    Exception in thread "main" java.lang.NumberFormatException:
    at java.lang.Integer.parseInt(Integer.java:426)
    at java.lang.Integer.<init>(Integer.java:540)
    at sun.jdbc.odbc.JdbcOdbcCallableStatement.getInt(JdbcOdbcCallableStatement.java:385)
    at test_proc.main(test_proc.java:11)
    How can i get the correct result: 1111
    Note: The Oracle jdbc driver can gets the correct result.
    Pls help me! Thanks!

    Hello,
    I presume you have created the stored procedure with an INOUT parameter?

Maybe you are looking for

  • Is there any way of going back to ios 6? 7 too slow on 4

    I downloaded ios 7 for my iPhone 4 yesterday and it's basically ruined my phone, the speed and performance of the phone is ridiculously slow, I find myself typing without knowing what I'm typing until it finally catches up... Is there any way of me g

  • Hide Button in Applications WD ABAP Standard

    Dear Experts. Please can someone help me with suggestions for the following issue that I have in this moment: I need hide the button "Entrada Nueva" for the component fitv_vc_advances [fitv_vc_advances|http://img842.imageshack.us/img842/2719/fitvvcad

  • Question about installing logic 9 upgrade on new computer

    Hello! I just purchased a new mac pro (woo hoo... finally) and the logic 9 upgrade pack. I own Logic 8 but I'm not sure if I should install it before installing the logic 9 upgrade. Will I miss out on any parts of the logic 8 sound library, loops, ef

  • IDVD Refuses To Recognize 15:9 NTSC Anamorphic from Final Cut Pro

    I read the following article on getting iDVD to recognize an anamorphic 16:9 video from Final Cut Pro: http://support.apple.com/kb/TS2179 My movie says it is in 16:9 anamorphic in QuickTime Pro, and the window is sized properly, but when I drop the m

  • IPhone 5 not working with Honda

    I have a 2011 Honda CR-Z and when I connect my iPhone 5 to the USB jack I either get an unsupported message or it only loads 54 of my 450 songs.  Anyone else having this type of issue? Is there a fix?