欢迎来到天天文库
浏览记录
ID:51690464
大小:34.45 KB
页数:2页
时间:2020-03-15
《Java操作Oracle数据库(建表插数据删除).doc》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、importjava.net.URL;importjava.sql.*;publicclassCreate{publicCreate(){}publicstaticvoidmain(String[]args){Stringurl="jdbc:oracle:thin:@10.0.1.3:1521:SDCDB";Stringquery="CREATETABLEMYFIRST"+"(idINT,nameCHAR(10))";Stringsql="insertintoMYFIRSTvalues('1','liming')";Stringsql1="insertinto
2、MYFIRSTvalues('2','mm')";Stringsql2="deleteMYFIRSTwhereid=2";try{Class.forName("oracle.jdbc.driver.OracleDriver");Connectionconn=DriverManager.getConnection(url,"test","test");Statementstmt=conn.createStatement();stmt.executeUpdate(query);stmt.executeUpdate(sql);stmt.executeUpdate(s
3、ql1);stmt.executeUpdate(sql2);System.out.println("CreateSuccess!");stmt.close();conn.close();}catch(java.lang.ClassNotFoundExceptione){System.err.print(e.getMessage());}catch(SQLExceptionex){System.out.println("***SQLExceptioncaught***");}}}
此文档下载收益归作者所有