Mysql的驱动:
public PersonOperation() {
try {
Class.forName("com.mysql.jdbc.Driver");
try {
connection = DriverManager.getConnection(
"jdbc:mysql://localhost:3306/linger", "root", "123456");
//"jdbc:mysql://localhost:3306/checkcode?useUnicode=true&characterEncoding=utf-8";
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// connection = DBPool.getConnection();
}
Oracle的驱动:
public class Driver {
public static void main(String[] args) throws IOException,
InstantiationException, IllegalAccessException,
ClassNotFoundException {
Connection con = null;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
con = DriverManager.getConnection(
"jdbc:oracle:thin:@localhost:1521:orcl", "system", "sys");
System.out.println("连接Oracle数据库成功");
Statement statement = con.createStatement();
ResultSet resultSet = statement
.executeQuery("select * from scott.emp");
while (resultSet.next()) {
System.out.print(resultSet.getString(1));
System.out.print(resultSet.getString(2));
System.out.print(resultSet.getString(3));
System.out.println(resultSet.getString(4));
}
} catch (SQLException e) {
}
}
}
关键词标签:Oracle,mysql
相关阅读
热门文章 Oracle中使用alter table来增加,删除,修改列的语法 oracle中使用SQL语句修改字段类型-oracle修改SQL语句案例 误删Oracle数据库实例的控制文件 为UNIX服务器设置Oracle全文检索
人气排行 oracle中使用SQL语句修改字段类型-oracle修改SQL语句案例 Oracle中使用alter table来增加,删除,修改列的语法 ORACLE SQL 判断字符串是否为数字的语句 ORACLE和SQL语法区别归纳(1) oracle grant 授权语句 ORACLE修改IP地址后如何能够使用 如何加速Oracle大批量数据处理 Oracle删除表的几种方法
查看所有1条评论>>