import java.sql.*;
public class TestJdbc {
public static void main(String args[]){
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
String hostIp="";//你的服务器ip
String ORACLE_SID="";//你的oracleSid
String user="";//你的用户名
String pass="";//你的密码
String url="jdbc:oracle:thin:@"+hostIp+":1521:"+ORACLE_SID;
Connection conn=DriverManager.getConnection(url,user,pass);
Statement stmt=conn.createStatement();
ResultSet rs=stmt.executeQuery("select * from tab");
while (rs.next()){
System.out.println(rs.getString(1));
}
conn.close();
stmt.close();
}catch(Exception e){
System.out.println(e);
}
}
}