www.pudn.com > bookshop.zip > DB.java, change:2013-07-10,size:470b


package com.tarena.util; 
 
import java.sql.Connection; 
import java.sql.DriverManager; 
 
 
public class DB { 
	static { 
		try{ 
			Class.forName("com.mysql.jdbc.Driver"); 
		}catch(Exception e) 
		{e.printStackTrace();} 
	} 
 
    //获得链接的方法 
    public static Connection getCon() throws Exception 
    { 
    	String url = "jdbc:mysql://localhost:3306/dang"; 
    	Connection con = DriverManager.getConnection(url,"root","ROOT"); 
		return con; 
    } 
 
 
}