Welcome to the Java Community Forum and interact with 2 million technical staff to access a series of operation code and operation result database content such as inserting, searching, and deleting MySQL database content: java source code: (the Code implements the query of the personnel information with a score of 100, and there are comments in the code of other functions) Note: run the program in eclipse
Welcome to the Java Community Forum, and interact with 2 million technical staff> enter a series of operation code and running result database content such as inserting, searching, and deleting MySQL database content: java source code: (the Code implements the query of the personnel information with a score of 100, and there are comments in the code of other functions) Note: run the program in eclipse
Welcome to the Java Community Forum and interact with 2 million technical staff> enter
Insert, search, and delete a series of operation codes and running results for MySQL database content
Database content:
Java source code: (the Code implements the query of personnel information with a score of 100. For other functions
Comments in the Code)
Note: When running a program in eclipse, You need to insert the jar package into the project; otherwise, an exception occurs!
Import java. SQL .*;
Import java. io .*;
Class database_manage {
Public Connection conn = null;
Public ResultSet rs = null;
Private String DatabaseDriver = "com. mysql. jdbc. Driver ";
// DataSource data source name DSN
Private String DatabaseConnStr = "jdbc: mysql: // localhost: 3306/lele_manage? UseUnicode = true & characterEncoding = utf8"
+ ", Root, root ";
Public void setDatabaseDriver (String Driver ){
This. DatabaseDriver = Driver;
}
Public String getDatabaseDriver (){
Return (this. DatabaseDriver );
}
Public void setDatabaseConnStr (String ConnStr ){
This. DatabaseConnStr = ConnStr;
}
Public String getDatabaseConnStr (){
Return (this. DatabaseConnStr );
}
Public database_manage () {// constructor connects to the database
Try {
Class. forName (DatabaseDriver );
} Catch (java. lang. ClassNotFoundException e ){
System. err. println ("error loading drive:" + e. getMessage ());
System. out. print ("insert execution error:" + e. getMessage (); // output to the client
}
}
[1] [2]