Results 1 to 4 of 4
  1. #1
    lipun4u is offline Member
    Join Date
    Jul 2009
    Location
    bhubaneswar
    Posts
    5
    Rep Power
    0

    Question insert query in odbc

    why the following code gives error ???

    import java.sql.*;

    public class Main {

    /**
    * @param args
    */
    public static void main(String[] args) throws Exception {
    // TODO Auto-generated method stub
    Class.forName("jdbc.odbc.JdbcOdbcDriver");
    Connection con = DriverManager.getConnection("jdbc:odbc:dsn1", "scott", "tiger");
    Statement stmt = con.createStatement();
    int x = stmt.executeUpdate("insert into emp (empno, ename, job) values (1000, 'asit dhal', 'clerk')");
    System.out.println(x + " rows updated");
    con.close();

    }

    }

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,861
    Rep Power
    19

    Default

    1. What error are you getting (stack trace and all), and on what line...ie point out the line.

    2. Put code in CODE tags to retain the formatting there's a button ('#') above the message box.

  3. #3
    Harpreet1111 is offline Member
    Join Date
    Jul 2009
    Posts
    12
    Rep Power
    0

    Default

    hello lipun4u,

    it is sun.jdbc.odbc.JdbcOdbcDriver.
    create the appropriate dsn and run....

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,861
    Rep Power
    19

    Default

    By the way, if this is an Oracle db (and it looks like it might be, unless scott/tiger is used by everyone as a demo login) you should be using the Oracle drivers.

Similar Threads

  1. Connect to Access without MS ODBC?
    By ribbs2521 in forum New To Java
    Replies: 5
    Last Post: 04-16-2009, 03:33 AM
  2. Help me this error in JDBC-ODBC connection
    By lordelf in forum Java Servlet
    Replies: 3
    Last Post: 04-04-2009, 08:37 AM
  3. Replies: 3
    Last Post: 02-28-2009, 09:17 AM
  4. Using JDBC-ODBC bridge
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 02-06-2008, 09:21 AM
  5. without ODBC
    By Heather in forum JDBC
    Replies: 2
    Last Post: 06-29-2007, 02:42 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •