import java.sql.DriverManager;
import java.sql.SQLException;

public class SelectTest {
private static java.sql.Connection con = null;
static String DB = “locationdb";
static String table = “p0000″;
public static void main(String[] args) {

try {
Class.forName(“com.mysql.jdbc.Driver");
// 註冊driver
con = DriverManager
.getConnection(
“jdbc:mysql://localhost/"+DB+"?useUnicode=true&characterEncoding=UTF-8″,
“root", “xxxx");

} catch (ClassNotFoundException e) {

System.out.println(“DriverClassNotFound :" + e.toString());
}// 有可能會產生sqlexception
catch (SQLException x) {
System.out.println(“Exception :" + x.toString());
}
}
}