Results 1 to 2 of 2
  1. #1
    shaungoater is offline Member
    Join Date
    Nov 2007
    Posts
    13
    Rep Power
    0

    Default SQL Insert Help!!!!

    I am using the following line of code to insert values into a database...

    Java Code:
    try{
                        String sql, imagePath= s;
                        // First, tell Java what driver to use and where to find it.
                        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                        // Next, create a connection to your data source.
                        // Specify that you are using the ODBC-JDBC Bridge.
                        // And specify the data source from ODBC.
                        con = DriverManager.getConnection("jdbc:odbc:Temp");
                        // Create an SQL statement.
                        Statement stmt = con.createStatement();
                        // Execute some SQL to create a table in your database.
                        // If the table already exists, an exception is thrown!
                        stmt.executeUpdate("INSERT INTO imageDatabase [path , keyword1] VALUES (+imagePath+,'landscape')");
                        
                    }
                    // Catch any exceptions that are thrown.
                    catch(ClassNotFoundException e){
                        
                        System.out.println(e.toString());
                        
                    } catch(SQLException e){
                        
                        System.out.println(e.toString());
    imagePath is a variable. When i run the above code i get the following error.

    Data source name not found and no default driver specified

  2. #2
    ferranb is offline Member
    Join Date
    Jun 2008
    Posts
    22
    Rep Power
    0

    Default

    Which database are working on? Have you validate it from another software?

Similar Threads

  1. How can i insert a char into a string
    By Jamie in forum New To Java
    Replies: 8
    Last Post: 02-17-2011, 09:59 PM
  2. Replies: 3
    Last Post: 07-12-2010, 08:15 AM
  3. How to insert graph in java
    By valery in forum Advanced Java
    Replies: 1
    Last Post: 08-06-2007, 09:38 PM
  4. How do insert a Graphic
    By carl in forum New To Java
    Replies: 1
    Last Post: 08-01-2007, 06:30 AM
  5. how to insert tables into JTextPane
    By osval in forum AWT / Swing
    Replies: 1
    Last Post: 07-29-2007, 10:11 AM

Posting Permissions

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