Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2044574
  • 博文数量: 519
  • 博客积分: 10070
  • 博客等级: 上将
  • 技术积分: 3985
  • 用 户 组: 普通用户
  • 注册时间: 2006-05-29 14:05
个人简介

只问耕耘

文章分类

全部博文(519)

文章存档

2016年(1)

2013年(5)

2011年(46)

2010年(220)

2009年(51)

2008年(39)

2007年(141)

2006年(16)

我的朋友

分类: Java

2010-01-11 11:59:14

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
阅读(1024) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~