package jk.action;
/*
- To change this template, choose Tools | Templates
- and open the template in the editor. */
/**
*
-
@author Administrator
/
import java.sql.;
public class link {
String userName="root";
//密码
String userPasswd="123456";
//数据库名
String dbName="tushuguanli";Connection con;
public Statement st;
public ResultSet rs;public link(){////用来链接mysql数据库的类,其他Action类可以调用它来完成对数据库的操作
try{
Class.forName("com.mysql.jdbc.Driver").newInstance();
//String url="jdbc:mysql://localhost/"+dbName+"?user="+userName+"&password="+userPasswd;
String url="jdbc:mysql://localhost:3306/dbName?user=root&password=userPasswd";
Connection con=DriverManager.getConnection(url);
Statement st=con.createStatement();
}catch(java.lang.Exception e) { System.out.println("Link DB error "+e.getMessage()); }
}
}