编程语言

img andunkafei

JDBC连接Oracle和Mysql数据库示例

发表于2004/10/8 9:22:00  2214人阅读

分类: 【Java】

 import java.sq.*;
 
 Connection conn = null;
 Statement stmt;
 ResultSet rs;  
  
 String sql = "select * from tab " ;

 //con = DriverManager.getConnection("jdbc:poolman://tgpms-help");

 //连接Oracle数据库
 Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
 conn = DriverManager.getConnection("jdbc:oracle:thin:@192.168.15.248:1521:ycdb","webcfcquery","kill859");
 
//连接Mysql数据库
 Class.forName("org.gjt.mm.mysql.Driver").newInstance();
 conn = DriverManager.getConnection("jdbc:mysql://localhost/meeting","root","21century");
 
  
 stmt = con.createStatement();
 rs = stmt.executeQuery(sql);  
 
 rs.close();
 stmt.close();
 con.close();

阅读全文
0 0

相关文章推荐

img
取 消
img