0
  package dbconn;

  import java.sql.*;

   public class DBConn {

        public static void main(String[] args) throws SQLException {
            String host = "jdbc:mysql://localhost/db_prac";
            String userName = null;
            String passCode = null;

           Connection conn = null;
           ResultSet resultSet = null;
          Statement statement = null;

        try {
           Class.forName("com.mysql.jdbc.Driver");
           conn = DriverManager.getConnection(host, userName, passCode);

        } catch(Exception e) {
           System.err.print("Error");
         }
        }
       }

I've been trying to connect jdbc with mysql but I'm constantly unsuccessful. I'm getting error at runtime at forName() and getConnection() methods. I am absolutely blank what is wrong, where am I going wrong. This is my code which is creating problems. But when copying and pasting someone else program into my IDE(Eclipse And Netbeans both) it gives error at runtime too.Below is the image of the libraries with I've added. I am tired of searching the results on google. help is needed

0 Answers0