package c1;
import java.sql.*;
import java.util.Properties;
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
//Test t=new Test();
//select * from dba_tablespaces
try{
DriverManager.registerDriver ( new oracle.jdbc.driver.OracleDriver());
Properties conProps = new Properties();
conProps.put("user", "sys");
conProps.put("password", "test");
conProps.put("defaultRowPrefetch", "15");
conProps.put("internal_logon", "sysdba");
// Connection conn= DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:test","system","test");
Connection conn= DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:test",conProps);
PreparedStatement pstmt = conn.prepareStatement("select * from dba_tablespaces");
ResultSet rset = pstmt.executeQuery();
while (rset.next()){
System.out.println (rset.getString(1)); // Print col 1
}
pstmt.close();
}
catch(SQLException e){e.printStackTrace();}
}
}
输出结果:
SYSTEM
UNDOTBS1
SYSAUX
TEMP
USERS
阅读(1047) | 评论(0) | 转发(0) |