conn=OracleJdbcUtil.getConnection();

package com.tfy.oracle.jbbc;


import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;


import org.junit.Test;


import com.tfy.oracle.util.DbcpUtil;
import com.tfy.oracle.util.OracleJdbcUtil;


public class OracleTest1 {

@Test
public void queryAllEmp(){
String sql="select * from emp";
Connection conn=null;
PreparedStatement pst=null;
ResultSet rs=null;
try{
// conn=OracleJdbcUtil.getConnection();
conn=DbcpUtil.getConnection();
pst= conn.prepareStatement(sql);

rs=pst.executeQuery();
while(rs.next()){
String name=rs.getString("ename");
String job=rs.getString("job");
double sal=rs.getDouble("sal");
System.out.println("name="+name+" job="+job+" sal="+sal);
}

}catch(Exception e){
e.printStackTrace();
}finally{
OracleJdbcUtil.realese(conn, pst, rs);
}
}
}

你可能感兴趣的:(conn=OracleJdbcUtil.getConnection();)