How to connect to mysql in MapReduce temporarily?

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

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

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.