How to make MySql connect with Java?
-
So, I have a database in MySql, and i want to use the database in a java application. I dont know how to connect the two. The database in Sql is called "restaurants" I've tried the following code: Connection con = null; try { Class.forName("com.mysql.jdbc.Driver… String url = "jdbc:mysql://localhost/restaurants"; String user = "root"; String pw = "admin"; con = DriverManager.getConnection(url, user, pw); } catch(ClassNotFoundException e) { System.out.println("e.getMessage()"… System.exit(0); } catch(SQLException e) { System.out.println(e.getMessage()); System.exit(0); } return con; } when i run the program, it keeps sending me the error message "com.mysql.jdbc.Driver" but thats the classpath where the driver is located. before i did this though, i set the environmental variables of the class path to where the connector bin folder is located. im soo confused...thanks.
-
Answer:
You must download the MySQL driver that will connect you with the DB by means of JDBC. Use this to connect: http://dev.mysql.com/downloads/connector/j/
mayi o at Yahoo! Answers Visit the source
Related Q & A:
- How do I make a window in Java?Best solution by Stack Overflow
- How to hybrid Mysql and MongoDB in Play framework?Best solution by Stack Overflow
- How to reset mysql password without old password?Best solution by Super User
- How to make a MySql query faster?Best solution by Stack Overflow
- How do I make my web browser java compatible?Best solution by answers.yahoo.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.