标签:acl pass void res prepare static sys jdb close
package com.test.jdbc; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; public class Test4 { public static void main(String[] args) { try { findPc(); } catch (Exception e) { // TODO 自动生成的 catch 块 e.printStackTrace(); } } public static void findPc() throws Exception{ //加载驱动 Class.forName("oracle.jdbc.driver.OracleDriver"); //获取连接 String url = "jdbc:oracle:thin:@localhost:1521:XE"; String user = "orac"; String password = "123456"; Connection conn = DriverManager.getConnection(url, user, password); //获取执行对象 String sqlStr = "delete from pc where pname=‘k665‘"; PreparedStatement pst = conn.prepareStatement(sqlStr); //调用方法处理,获取结果 int num = pst.executeUpdate(); //处理结果 if(num>0) System.out.println("删除成功"); else System.out.println("删除失败"); //关闭 pst.close(); conn.close(); } }
标签:acl pass void res prepare static sys jdb close
原文地址:http://www.cnblogs.com/a1045417817/p/7498462.html