欢迎投稿

今日深度:

jdbc与数据库Oracle链接的自练习

jdbc与数据库Oracle链接的自练习


myeclipse里面导入新的项目

右键>import>General>existing...>next>select root >browse>项目>finish

导jar包

右键>properties>java build path >libraries>ojdbc14-10.2.0.3.jar

获取本机ip地址cmd>ipconfig

ipv4的地址为自己的地址

Class.forName("oracle.jdbc.driver.OracleDriver");
String url="jdbc:oracle:thin:@127.0.0.1:1521:xe";
String user = "scott";
String password="tiger";
Connection conn = DriverManager.getConnection(url,user,password);

PreparedStatement pstam = conn.prepareStatement("select * from userinfo ");

ResultSet rs = pstam.executeQuery();
while(rs.next()){
System.out.println(rs.getInt("id")+rs.getString("name")+rs.getInt("age"));
}

pstam.close();
conn.close();

www.htsjk.Com true http://www.htsjk.com/oracle/22442.html NewsArticle jdbc与数据库Oracle链接的自练习 myeclipse里面导入新的项目 右键importGeneralexisting...nextselect root browse项目finish 导jar包 右键propertiesjava build path librariesojdbc14-10.2.0.3.jar 获取本机ip地址cmdipcon...
评论暂时关闭