Answer to Question #23743 in Java | JSP | JSF for Sourabh Vishal

Question #23743
getting error as "com.mysl.jdbc.Driver" when trying to run a simple programe named as iit registration
1
Expert's answer
2013-02-05T08:30:20-0500
Firstly, to start working with MySQL database in Java youhave to download the JDBC driver (or howit is called MySQL connector). Install it.

Secondly, in your code you have to import some packagesfrom it:

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

Then when trying to access to your database:
try {
Class.forName("com.mysql.jdbc.Driver"); //loading your JDBC driver Connection connect =
DriverManager.getConnection("jdbc:mysql:databasename”, “login”,
“password”); Statement statement = connect.createStatement(); // Result set get
the result of the SQL query ResultSet resultSet =
statement.executeQuery("select * from table_name"); } catch
(SQLException e) {
throwe;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS