package com;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class DBTest {
/**
-
@param args
*/private static final String url="jdbc:mysql://localhost:3306/db_shop";
private static final String name="root";
private static final String password="root";static{
try {
//加载驱动程序;
Class.forName("com.mysql.jdbc.Driver");
//获得数据库连接;
}catch(ClassNotFoundException e){
e.printStackTrace();
}
}
public static void main(String[] args){
try{
Connection conn=DriverManager.getConnection(url,name,password);
System.out.println("数据库连接成功"+conn);
}catch(SQLException e){
e.printStackTrace();
}
}New Database Connection Driver中Test Driver出现Error while performing database login with the db_shop driver:Unable to create connection.Check your URL.