/*
 * Created on 2007-4-20
 *
 * To change the template for this generated file go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */
package org.pan.util;/**
 * @author new
 *
 * To change the template for this generated type comment go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */
import java.sql.*; public class DBTest{ 
public static void main(String[] args) { 
String driver = "org.gjt.mm.mysql.Driver";
String url = "jdbc:mysql://localhost:3306/business";
String user = "root"; 
String password = "aa"; 
try {
Class.forName(driver); 
Connection conn = DriverManager.getConnection(url, user, password); 
if(!conn.isClosed()) 
System.out.println("数据库连接成功!"); 
conn.close(); 

catch(ClassNotFoundException e) { 
System.out.println("找不到驱动程序"); 
e.printStackTrace(); 

catch(SQLException e) { 
e.printStackTrace(); 


}出错信息java.sql.SQLException: Communication failure during handshake. Is there a server running on localhost:3306?
at org.gjt.mm.mysql.MysqlIO.init(MysqlIO.java:327)
at org.gjt.mm.mysql.Connection.connectionInit(Connection.java:261)
at org.gjt.mm.mysql.jdbc2.Connection.connectionInit(Connection.java:89)
at org.gjt.mm.mysql.Driver.connect(Driver.java:167)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at org.pan.util.DBTest.main(DBTest.java:25)