?? dbtest.java
字號:
package com.ibm.action;
import java.sql.*;
public class DBTest {
public static void main(String[] args) {
String driver = "com.mysql.jdbc.Driver";
String url = "jdbc:mysql://localhost:3306/test";
String user = "root";
String password = "lihui";
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();
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -