18.9.12 下午 第38天上课

18.9.12 下午 第38天上课

18.9.12 下午 第38天上课

18.9.12 下午 第38天上课

18.9.12 下午 第38天上课

18.9.12 下午 第38天上课

 

18.9.12 下午 第38天上课

18.9.12 下午 第38天上课

public class Orc6 {
    private static final String URL="jdbc:oracle:thin:@localhost:1521:orcl";
    private static final String USER="scott";
    private static final String PASSWORD="123";
    private static final String OJDOD="oracle.jdbc.driver.OracleDriver";
    private Connection conn;
    private PreparedStatement pre;
    private ResultSet rs;
    public static Connection getConnection() {
try {
    Class.forName(OJDOD);
    Connection conn=DriverManager.getConnection(URL,USER,PASSWORD);
    return conn;
}catch(Exception e) {
    e.printStackTrace();
}
    return null;    
    }
    public static int updateForSql(String sql,Object...obj) {
        Connection conn=null;
        PreparedStatement pre =null;
        try {
            conn=getConnection();
            pre=conn.prepareStatement(sql);
            for(int i=0;i<obj.length;i++) {
                pre.setObject(i+1,obj[i]);
            }
            int row=pre.executeUpdate();
            return row;
        }catch(Exception e) {
            e.printStackTrace();
        }finally {
            
        }
        return 0;
    }
}

public class Test {
    public int sava(String cardnum,String balance) {
        String sql="insert into T values(6,?,?)";
        return Orc6.updateForSql(sql,cardnum,balance);
    }    
    public static void main(String[]args) {
        Test t=new Test();
        t.sava("09","400");
    }
}