mysql数据库连接:JAVA连接mysql数据库

·········10········20········30········40········50········60········70········80········90········100·······110·······120·······130·······140·······150
//java连接mysql数据库
import java.sql.*;

public Myproject
{
public void (String args){
try{
Class.forName("org.gjt.mm.mysql.Driver");

String url="jdbc:mysql://localhost:3306/my";
String username="root";
String password="123456";
Connection con
=DriverManager.getConnection(url,username,password);
num=100;
PreparedStatement statement
=con.prepareStatement("INSERT INTO useers VALUES(?,?)");
for( i=0;i<num;i){
statement.String(1,"bobuke"+1);
statement.String(2,"bo"+1);
statement.executeUpdate;
}
}

catch(Exception e){
.out.prln("An error has occurred:"+e.toString);
e.prStackTrace;
}
}
}
Tags:  jsp连接mysql数据库 php连接mysql数据库 asp连接mysql数据库 mysql数据库连接

延伸阅读

最新评论

发表评论