Home > database >  The IDEA of importing the JDBC package
The IDEA of importing the JDBC package

Time:11-22

The import has been unsuccessful


 
import java.sql.*;

Public class JdbcDemo1 {
Public static void main (String [] args) throws ClassNotFoundException, SQLException {
//1. Import the driver jar package
//2. The registration drive
Class.forname (". Com. Mysql. Cj. JDBC Driver ");
//Class. Class.forname (org. GJT. Mm. Mysql. "Driver");
//3. Access to the database connection object
The Connection conn=
DriverManager. GetConnection (" JDBC: mysql//localhost: 3306/school ", "root", "123456");
//4. Define the SQL statement
String SQL="update students set ` name `='sora aoi' where id=4";
//5. Access to objects of executing SQL Statement
The Statement STMT=conn. CreateStatement ();
//6. Execute SQL
Int count=STMT. ExecuteUpdate (SQL);
//7. Process the results
System. The out. Println (count);
//8. Release resources
STMT. Close ();
conn.close();
}
}


An error is as follows:



Code should be no problem, the jar has import


Online solutions are tried, it won't work, learn Mysql card here, ill, a great god for help




CodePudding user response:

 


import java.sql.*;

Public class JdbcDemo1 {
Public static void main (String [] args) throws ClassNotFoundException, SQLException {
//1. Import the driver jar package
//2. The registration drive
Class.forname (". Com. Mysql. Cj. JDBC Driver ");
//Class. Class.forname (org. GJT. Mm. Mysql. "Driver");
//3. Access to the database connection object
The Connection conn=
DriverManager. GetConnection (" JDBC: mysql//localhost: 3306/school ", "root", "123456");
//4. Define the SQL statement
String SQL="update students set ` name `='sora aoi' where id=4";
//5. Access to objects of executing SQL Statement
The Statement STMT=conn. CreateStatement ();
//6. Execute SQL
Conn. The open ();
Int count=STMT. ExecuteUpdate (SQL);
//7. Process the results
System. The out. Println (count);
//8. Release resources
STMT. Close ();
conn.close();
}
}


CodePudding user response:

refer to the second floor one tree forest _ response:
 


import java.sql.*;

Public class JdbcDemo1 {
Public static void main (String [] args) throws ClassNotFoundException, SQLException {
//1. Import the driver jar package
//2. The registration drive
Class.forname (". Com. Mysql. Cj. JDBC Driver ");
//Class. Class.forname (org. GJT. Mm. Mysql. "Driver");
//3. Access to the database connection object
The Connection conn=
DriverManager. GetConnection (" JDBC: mysql//localhost: 3306/school ", "root", "123456");
//4. Define the SQL statement
String SQL="update students set ` name `='sora aoi' where id=4";
//5. Access to objects of executing SQL Statement
The Statement STMT=conn. CreateStatement ();
//6. Execute SQL
Conn. The open ();
Int count=STMT. ExecuteUpdate (SQL);
//7. Process the results
System. The out. Println (count);
//8. Release resources
STMT. Close ();
conn.close();
}
}




Where is the great god, and changed, and I didn't see the

CodePudding user response:

reference 3 floor Running - code response:
Quote: refer to the second floor one tree forest _ response:

 


import java.sql.*;

Public class JdbcDemo1 {
Public static void main (String [] args) throws ClassNotFoundException, SQLException {
//1. Import the driver jar package
//2. The registration drive
Class.forname (". Com. Mysql. Cj. JDBC Driver ");
//Class. Class.forname (org. GJT. Mm. Mysql. "Driver");
//3. Access to the database connection object
The Connection conn=
DriverManager. GetConnection (" JDBC: mysql//localhost: 3306/school ", "root", "123456");
//4. Define the SQL statement
String SQL="update students set ` name `='sora aoi' where id=4";
//5. Access to objects of executing SQL Statement
The Statement STMT=conn. CreateStatement ();
//6. Execute SQL
Conn. The open ();
Int count=STMT. ExecuteUpdate (SQL);
//7. Process the results
System. The out. Println (count);
//8. Release resources
STMT. Close ();
conn.close();
}
}




Where is the great god, and changed, and I didn't see the
ok?

CodePudding user response:

reference one tree forest, 4/f, _ response:
Quote: refer to the third floor Running p-code response:

Quote: refer to the second floor one tree forest _ response:

 


import java.sql.*;

Public class JdbcDemo1 {
Public static void main (String [] args) throws ClassNotFoundException, SQLException {
//1. Import the driver jar package
//2. The registration drive
Class.forname (". Com. Mysql. Cj. JDBC Driver ");
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related