1. 程式人生 > >將myeclipse和mysql連接起來的關鍵語句

將myeclipse和mysql連接起來的關鍵語句

pan encoding spa use char 語句 myeclips ren manage

 1       String driverName="com.mysql.jdbc.Driver";
 2       String userName="root";
 3       String userPwd="123456";
 4       String dbName="students";
 5       String url1="jdbc:mysql://localhost:3306/"+dbName;
 6       String url2="?user="+userName+"&password="+userPwd;
 7       String url3="&useUnicode=true&characterEncoding=UTF-8";
8 String url=url1+url2+url3; 9 Class.forName(driverName); 10 Connection conn=DriverManager.getConnection(url);

將myeclipse和mysql連接起來的關鍵語句