RSS
热门关键字:  java  Ajax  JSP  JSF  Struts
当前位置 : 首页>JSP>列表

JDBC

来源: 作者: 时间:2007-08-26 点击:
           PreparedStatement ps=null;

          

           try{

                 con=JdbcUtil.getConnection();

                 ps=con.prepareStatement(sql);

                

                 ps.setInt(1,2);

                 ps.setString(2,"zhangsan");

                 ps.executeUpdate();

                

                 ps.setInt(1,3);

                 ps.setString(2,"lisi");

                 ps.executeUpdate();

                

           }catch(Exception e){

                 e.printStackTrace();

           }finally{

                 JdbcUtil.close(con,ps);

                 }

           }

      }

 

package moudule1.com;

 

import java.sql.*;

 

public class JdbcUtil{

     

      public static Connection getConnection() throws Exception{

           Class.forName("oracle.jdbc.driver.OracleDriver");

       return DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:name", "scott","tiger");

           }

          

      public static void close(Connection con,Statement st){

          

最新评论共有 0 位网友发表了评论
发表评论
评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
用户名: 密码:
匿名?
注册