Mysql:
1 ": http://www.mysql.com/products/connector/
2 "
jdbc:[database type]://[IP address]:[port number/[database name]
Private String URL = "Jdbc:mysql://localhost:3306/userdata";
Private String Driver = "Com.mysql.jdbc.Driver";
Private String user = "root";
Private String pass = "root123";
try{
class.forname ("Com.mysql.jdbc.Driver");//Load Driver
}
catch (ClassNotFoundException e)
{
E.getexception ();
}
insert into [table name] (column name 1, column name 2) VALUES (?,?)
[] can be omitted, () can not, there are several columns there are several question marks
String sql = "INSERT into Userdata.logn (User_logn,user_password) VALUES (?,?)"; /This string indicates the structure of the SQL statement
Connection cnn = drivermanager.getconnection (Url,user,pass);//Connection Database
PreparedStatement PREP = cnn.preparestatement (SQL);//Create PREPARED statement
String a = "ASDASDASD", b= "123456";
Prep.setstring (1,a);
Prep.setstring (2, B);
Prep.executeupdate ();//write data to the database, and may also throw SQL exceptions
Cnn.close ();
Java JDBC Driver MySQL