以下为引用的内容:
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Properties;
import oracle.jdbc.pool.OracleDataSource;
public class Main {
public static void main(String[] args) {
try{
OracleDataSource ods = new OracleDataSource();
ods.setDriverType ( "thin" ); // type of driver
ods.setNetworkProtocol("tcp"); // tcp is the default anyway
ods.setServerName ( "127.0.0.1" ); // database server name
ods.setDatabaseName("TEST"); // Oracle SID
ods.setPortNumber(1521); // listener port number
ods.setUser("user"); // username
ods.setPassword("123456"); // password
Connection conn=ods.getConnection();
PreparedStatement ps=conn.prepareStatement("select * from pipe");
ResultSet rs=ps.executeQuery();
while (rs.next())
{
String source = rs.getString("SOURCE_ID");
System.out.println( source );
}
System.in.read();
}
catch(Exception e)
{
System.out.println(e.getMessage());
}