package com.neusoft.utils;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class JdbcOracleTest {
/**
* @param args
*/
public static void main(String[] args) {
// 2.建立同数据库的连接
// url:统一资源定位符
String url = "jdbc:oracle:thin:@10.25.85.247:1521:orcl";
String user = "scott";
String password = "tiger";
Connection con = null;
Statement st = null;
String sql = "select * from DEPT";
String sql1 = "delete from USERTEST";
ResultSet rs = null;
PreparedStatement pst = null;
关闭资源
try {
if (rs != null) {
rs.close();
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
if (st != null) {
st.close();
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
if (pst != null) {
pst.close();
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
if (con != null) {
con.close();
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
jave学习第三节代码
最新推荐文章于 2024-07-21 10:59:30 发布