The following code is throwing "Exception: com.mysql.jdbc.Driver"
do i need to drop a driver file somewhere?
im fairly new to java, so be gentle
Help :-)
Expand|Select|Wrap|Line Numbers
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.SQLException;
- public class MySql {
- public static void main(String args[]) throws Exception
- {
- Connection con = null;
- try {
- Class.forName("com.mysql.jdbc.Driver").newInstance();
- con = DriverManager.getConnection("jdbc:mysql:///test",
- "username", "password");
- if(!con.isClosed())
- System.out.println("Successfully connected to " +
- "MySQL server using TCP/IP...");
- } catch(Exception e) {
- System.err.println("Exception: " + e.getMessage());
- } finally {
- try {
- if(con != null)
- con.close();
- } catch(SQLException e) {}
- }
- }
- }