Connection connection = null;
        Statement stmt = null;
        String strDriver = "oracle.jdbc.driver.OracleDriver";
        String strURL = "jdbc:oracle:thin:@192.168.210.88:1521:unieap";
        String strUser = "orgeap";
        String strPwd = "orgeap";
        String strSQL = "select * from cities";        try {
            Class.forName(strDriver);
            connection = DriverManager.getConnection(strURL, strUser, strPwd);
            stmt = connection.createStatement();            ResultSet rs = stmt.executeQuery(strSQL);
            
            .....
            
        } catch (Exception e) {
            ....
        }

解决方案 »

  1.   

    哦,忘了解释:
    unieap : 数据库的sid即全局名
    strUser : 用户名
    strPwd : 密码
      

  2.   

    http://www.cn-java.com/target/news.php?news_id=1054
    最好用连接池配!
      

  3.   

    动作好快。登录一下就回复了。
     try {
                Context env = (Context) new InitialContext().lookup("java:comp/env");
        
                pool = (DataSource) env.lookup("jdbc/test");
            
            } catch (NamingException e) {
              
            }在resion里的配置文件应该这样写了:
    <resource-ref>
      <res-ref-name>jdbc/test</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <init-param driver-name="oracle.jdbc.driver.OracleDriver"/>
      <init-param url="jdbc:oracle:thin:@192.168.210.88:1521:unieap"/>
      <init-param user=""/>
      <init-param password=""/>
      <init-param max-connections="20"/>
      <init-param max-idle-time="30"/>
    </resource-ref>抄袭一下。哈哈。
      

  4.   

    要不要在环境变量里设置classpath?
    可以不用jdbc桥连接吗?