您的位置:首页 > 数据库

使用JDBC连接Windchill数据库

2013-04-07 20:38 281 查看
要深入了解Windchill,就不得不了解Windchill的数据模型,平时工作中,不论是自己测试还是解决客户问题,都常常需要用Oracle的SQL Developer查询数据库,其实之前就想能不能把常用的查询做成一个小程序,好方便使用,今天就开始第一步,连接数据库,代码如下:

import java.sql.*;
public class ConnectJDBC {
public static final String DBURL="jdbc:oracle:thin:@localhost:1521:wind";
public static final String DBUSER = "oracle";
public static final String DBPASS = "ts";
public static void main(String[] args) throws Exception{
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
try{
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
conn = DriverManager.getConnection(DBURL,DBUSER,DBPASS);
System.out.println(conn);
}catch(SQLException e){
System.out.println("An exception occurs: " + e.getMessage());
e.printStackTrace();
}finally{
if(rs != null)
rs.close();
if(stmt != null)
stmt.close();
if(conn != null)
conn.close();
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: