JDBC Exception #74
-
|
sir I had write this simple code to connect to database using JDBC , Also download a JDBC MySQL connector jar file & also set a class path of it in my eclipse project but when I run a program it shows me a Exception Code package connection;
//Steps
// 1 import
// 2 load and register
// 3 create the statement
// 4 execute the query
// 5 process the query
// 7 close
import java.sql.*;
public class JDBC {
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
Class.forName("com.mysql.cj.jdbc.Driver");
Connection con = DriverManager.getConnection("jdc:mysql://localhost:3306/school", "root", "Password");
Statement st = con.createStatement();
ResultSet rs = st.executeQuery("Select *from school where studentId = 1");
rs.next();
int studentId = rs.getInt("studentId");
String studentName = rs.getString("studentId");
String studentGrade = rs.getString("studentGrade");
String studentResult = rs.getString("studentResult");
System.out.println(studentId +" "+ studentName +" "+ studentGrade +" "+ studentResult);
st.close();
con.close();
}
}
```java
 |
Beta Was this translation helpful? Give feedback.
Answered by
akash-coded
May 21, 2022
Replies: 1 comment 2 replies
-
|
It is difficult to provide a resolution without having a look at your setup or project configuration. Make sure you have downloaded the MySQL Connector corresponding to your MySQL Server. @SankalpHP |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
SankalpHP
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It is difficult to provide a resolution without having a look at your setup or project configuration. Make sure you have downloaded the MySQL Connector corresponding to your MySQL Server. @SankalpHP