package com.test;
import java.sql.;
import java.util.;
public class Test {
//public static final String DRIVER = "oracle.jdbc.driver.OracleDriver";//oracle 驱动jar包在安装目录D:\ORACLE\product\11.2.0\dbhome_1\oui\jlib\classes12.jar
//public static final String URL = "jdbc:oracle:thin:@localhost:1521:orcl";
public static final String DRIVER = "com.mysql.cj.jdbc.Driver";
public static final String URL = "jdbc:mysql://localhost:3306/leaen?useSSL=false&serverTimezone=UTC";
public static final String USERNAME = "root";
public static final String PASSWORD = "root";
public static void main(String[] args) throws Exception {
Connection conn = null;
Class.forName(DRIVER).newInstance();// 找到oracle驱动器所在的类
conn=DriverManager.getConnection(URL, USERNAME, PASSWORD);
System.out.println(conn);
/*StringBuffer sql = new StringBuffer();
sql.append("select * from t_user");
PreparedStatement ps = conn.prepareStatement(sql.toString());
ResultSet rs = ps.executeQuery();
while (rs.next()) {
for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) {
System.out.print(rs.getObject(i) + "\t");
}
System.out.println('\n');
}*/
}
}
评论区