import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
public class Demo {
public static void main(String[] args) {
Connection conn = null;//连接
PreparedStatement ps = null;//sql
ResultSet rs = null;//结果集
try {
Class.forName("oracle.jdbc.driver.OracleDriver");//加载驱动
String url = "jdbc:oracle:thin:@192.168.3.222:1521:ORCL";
String user = "ntjmyj";
String password = "ntjmyj";
conn = DriverManager.getConnection(url, user, password);
String sql = "select * from T_XXWH_ZXWH";
ps = conn.prepareStatement(sql);
rs = ps.executeQuery();
while(rs.next()){
System.out.println(rs.getString("fid"));
}
} catch (Exception e) {
e.printStackTrace();
}finally{
try {
if(conn != nu
简单的JDBC查询数据库
最新推荐文章于 2023-08-28 11:33:04 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)