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修使用低权限Oracle数据库账户得到管理员权限Oracle对user的访问控制
人气排行 ORACLE SQL 判断字符串是否为数字的语句Oracle中使用alter table来增加,删除,修改列的语法ORACLE和SQL语法区别归纳(1)oracle grant 授权语句如何加速Oracle大批量数据处理Oracle删除表的几种方法ORACLE修改IP地址后如何能够使用Oracle 10g创建表空间和用户并指定权限
查看所有0条评论>>