ʹÓÃJAVAÁ¬½Ó³Ø×÷µÄÊý¾Ý¿âÔöɾ¸Ä²é.txt¤åÄã²»ÓÃÒ»ÉÏÏß¿´¼ûÝÔÚÏߣ¬¾Í¼±×ÅÒþÉí£¬·ÅÐÄ¡£Ý²»»áÈ¥²øÄ㡣˵ºÃµÄ²»Àë²»ÆúÏÖÔÚ·´¶ø×Ô¼ºÈ´×ö²»µ½¨roralceUitlPool.javapackagecom.oneworld.util;importjava.sql.Connection;importjava.sql.DriverManager;importjavax.naming.InitialContext;importjavax.sql.DataSource;/***@authormmode**/publicclassoralceUitlPool{staticConnectionconn=null;publicstaticConnectiongetConnection(){InitialContextinitctx;try{initctx=newInitialContext();DataSourceds=(DataSource)initctx.lookup(java:comp/env/jdbc/vodone);conn=ds.getConnection();}catch(Exceptione){e.printStackTrace();}returnconn;}publicstaticConnectionConnectToDB(){try{StringoURL=192.168.5.92;StringoPort=1521;StringoService=smsdb;StringoUser=gtsms;StringoPassword=gtsms;StringsdName=oracle.jdbc.driver.OracleDriver;Class.forName(sdName);StringconnStr=jdbc:oracle:thin:@+oURL+:+oPort+:+oService;conn=DriverManager.getConnection(connStr,oUser,oPassword);}catch(Exceptione){System.out.println(e);}returnconn;}publicstaticvoidmain(String[]args){oralceUitlPooloup=neworalceUitlPool();oup.getConnection();}}DBUtil.javapackagecom.oneworld.util;importjava.sql.Connection;importjava.sql.ResultSet;importjava.sql.SQLException;importjava.sql.Statement;/*******ʹÓÃÁ¬½Ó³ØÁ¬½ÓÊý¾Ý¿â,Ìṩ¶ÔÊý¾Ý¿â²Ù×÷µÄ¸÷¸ö½Ó¿Ú*@authormmode**/publicclassDBUtil{privateConnectionconn=null;privateStatementstmt=null;privateResultSetrs=null;publicDBUtil(){//conn=oralceUitlPool.getConnection();conn=oralceUitlPool.ConnectToDB();try{stmt=conn.createStatement();}catch(SQLExceptione){//TODOAuto-generatedcatchblocke.printStackTrace();}}/**************Êý¾Ý¿â²Ù×÷----Ôö¼Ó*@paramsql:½«ÒªÖ´ÐеÄSQLÓï¾ä*@return£ºÖ´Ðгɹ¦ÁË£¬·µ»Øtrue,Ö´Ðв»³É¹¦£¬·µ»Øfalse*/publicbooleanExeInser(Stringsql){booleanflag=true;try{stmt.execute(sql);flag=true;}catch(SQLExceptione){flag=false;e.printStackTrace();}returnflag;}/*********Êý¾Ý¿â²Ù×÷----ɾ³ý*@paramsql:½«ÒªÖ´ÐеÄSQLÓï¾ä*@return:Ö´Ðгɹ¦£¬·µ»Øtrue£¬Ö´ÐÐʧ°Ü£¬·µ»Øfalse;*@throwsSQLException*/publicbooleanExeDel(Stringsql)throwsSQLException{booleanflag=true;try{stmt.execute(sql);flag=true;}catch(SQLExceptione){flag=false;e.printStackTrace();}returnflag;}/*************Êý¾Ý¿â²Ù×÷----ÐÞ¸Ä*@paramsql:½«ÒªÖ´ÐеÄSQLÓï¾ä*@return:Ö´Ðгɹ¦,·µ»Øtrue,Ö´ÐÐʧ°Ü£¬·µ»Øfalse;*/publicbooleanExeUpdate(Stringsql){booleanflag=true;try{stmt.executeUpdate(sql);flag=true;}catch(SQLExceptione){flag=false;e.printStackTrace();}returnflag;}/***********Êý¾Ý¿â²Ù×÷------²éѯ*@paramsql:½«ÒªÖ´ÐеÄSQLÓï¾ä*@return£ºÖ´Ðгɹ¦£¬·µ»Øtrue,Ö´ÐÐʧ°Ü£¬·µ»Øfalse*/publicbooleanExeSelect(Stringsql){booleanflag=true;try{rs=stmt.executeQuery(sql);flag=true;}catch(SQLExceptione){flag=false;e.printStackTrace();}returnflag;}publicResultSetgetRS(){returnrs;}publicstaticvoidmain(Stringargs[])throwsSQLException{DBUtildbc=newDBUtil();booleanb=dbc.ExeSelect(select*fromgtsms.image_group_item);System.out.print(b);}}±êÇ©:ѧϰ³äµç(JAVA)