Re: need help to use java to connect to MYSQL DB
Alan Williamson <[email protected]> Thu, 29 Nov 2007 11:50:16 +0000
| Newsgroups | gmane.comp.db.mysql.java |
|---|---|
| Organization | Blog-City Ltd |
| Message-ID | <[email protected]> |
What is the exception that is printed out?
do not stop it in the debugger; let it run and read what the exception says
Eman Hossny wrote:
> Hi all,
> i need to use Eclipse(java SDK) to connect to MYSQL DB,
> & i write the following code for connection, but when i run it no thing
> happen, no output appear, & when i debug it, i found that the debuger was
> stopped @ the line
>
> conn=DriverManager.getConnection(connectionURL,"Eman","Eman");
>
> ----------------------------------------my code for connection
>
> String driver ="com.mysql.jdbc.Driver";
> String dbName="travel";
> String connectionURL = "jdbc:mysql://localhost/" + dbName;
> try{
> //load the driver
> Class.forName(driver).newInstance();
> conn=DriverManager.getConnection(connectionURL,"Eman","Eman");
> System.out.println("Successfully connected to " +
> "MySQL server using TCP/IP...");
> }
> catch(Exception e)
> {
> e.printStackTrace();
> System.out.println("Error "+e.getMessage());
> }
> -----------------------------------------
>
> -note: i added the connector/j.jar to the classpath environment variable
> -Is the connector/J version must be consistent with the jdk version?
> -i consume more time to solve this problem but till now didn't reach to any
> thing.any help please,
> waitting for reply
>
>
>
--
Alan Williamson
"a wiki -and- a blog" @ http://www.Blog-City.com/
b: http://alan.blog-city.com/
--
MySQL Java Mailing List
For list archives: http://lists.mysql.com/java
To unsubscribe: http://lists.mysql.com/[email protected]