Results 1 to 6 of 6
  1. #1
    pryncipe is offline Member
    Join Date
    Mar 2011
    Posts
    3
    Rep Power
    0

    Default Help! JDBC Connection Error

    Java Code:
    import java.sql.*;
    public class jdbc_test {
    	public static void main (String args[]) {
    		try {
    			Statement stmt;
    			
    			Class.forName("com.mysql.jdbc.Driver").newInstance();
    	
    			String url = "jdbc:mysql://localhost:3306/mysql";
    	
    			Connection conn = DriverManager.getConnection(url, "root", "");
    
    			System.out.println ("URL: "+ url);
    			System.out.println ("Connection: "+ conn);
    
    			stmt = conn.createStatement();
    
    			stmt.executeUpdate("CREATE DATABASE JunkDB");
    
    			conn.close();
    		}
    		catch (Exception e) {
    			e.printStackTrace();
    		}
    	}
    }
    i'm trying to connect this program to database. but it returns me errors. i place the connector to default classpath which is C:\Program Files\Java\jdk1.6.0_23 (Win7). also, i decided to move the connectors to other folder and specify the classpath but both of them still give me errors.



    help me please.
    Last edited by pryncipe; 03-18-2011 at 09:35 PM.

  2. #2
    FlyNn is offline Senior Member
    Join Date
    Feb 2010
    Posts
    128
    Rep Power
    0

    Default

    I think you need mysql one of these

    Download the JConnector and import it into your file.
    Measuring programming progress by lines of code is like measuring aircraft building progress by weight.

  3. #3
    pryncipe is offline Member
    Join Date
    Mar 2011
    Posts
    3
    Rep Power
    0

    Default

    Quote Originally Posted by FlyNn View Post
    I think you need mysql one of these

    Download the JConnector and import it into your file.
    I have those files in the specified classpath. how do i import it?

  4. #4
    FlyNn is offline Senior Member
    Join Date
    Feb 2010
    Posts
    128
    Rep Power
    0

    Default

    depending of which IDE you are using, its different.
    But it essence you need to add the API as a library. Which IDE are you using?
    Measuring programming progress by lines of code is like measuring aircraft building progress by weight.

  5. #5
    pryncipe is offline Member
    Join Date
    Mar 2011
    Posts
    3
    Rep Power
    0

    Default

    Quote Originally Posted by FlyNn View Post
    depending of which IDE you are using, its different.
    But it essence you need to add the API as a library. Which IDE are you using?
    just Notepad++.

  6. #6
    FlyNn is offline Senior Member
    Join Date
    Feb 2010
    Posts
    128
    Rep Power
    0

    Default

    I've never used Notepad++ you might need something more advance for importing libraries.
    Measuring programming progress by lines of code is like measuring aircraft building progress by weight.

Similar Threads

  1. Replies: 0
    Last Post: 02-16-2011, 02:30 PM
  2. JDBC connection to Cache - error
    By javavick in forum New To Java
    Replies: 1
    Last Post: 05-06-2010, 03:06 PM
  3. Error creating JDBC connection in Eclipse
    By tascoa in forum Eclipse
    Replies: 2
    Last Post: 11-06-2009, 11:20 AM
  4. Help me this error in JDBC-ODBC connection
    By lordelf in forum Java Servlet
    Replies: 3
    Last Post: 04-04-2009, 09:37 AM
  5. Replies: 0
    Last Post: 09-28-2007, 01:56 PM

Tags for this Thread

Posting Permissions

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