数据库连接检测

package com.duo;

import java.sql.Connection;
import java.sql.DriverManager;

import org.junit.Test;

public class Lianjie {
@Test
public void ceshi() throws Exception{
String url="jdbc:mysql://localhost:3306/mytest";
String diverString="com.mysql.jdbc.Driver";
String nameString="root";
String password="orcl";

Class.forName(diverString);
Connection connection=DriverManager.getConnection(url, nameString, password);
System.out.println(connection);
}
}

posted @ 2017-06-22 10:52  afterhoursprogramer  阅读(137)  评论(0编辑  收藏  举报