zoukankan      html  css  js  c++  java
  • java连接Oracle数据库

    import java.net.URL;
    import java.sql.*;

    public class JavaOracle {
      public JavaOracle() {
      }
    public static void main(String[] args){
      try
      {
        try{
          Class.forName("oracle.jdbc.driver.OracleDriver");
        }
        catch(java.lang.ClassNotFoundException e)
        {
          System.err.print(e.getMessage());
        }
        String url="jdbc:oracle:thin:@Server:1521:SDCDB";
        Connection conn=DriverManager.getConnection(url,"test","test");
        Statement stmt=conn.createStatement();
        ResultSet rs=stmt.executeQuery("select score from MY");
        while(rs.next())
        {
          System.out.println(rs.getString(1));
        }
        conn.close();
      }
      catch(SQLException ex)
      {
        while(ex!=null)
        {System.out.println(ex.getSQLState());
        }
      }
    }
    }

     

  • 相关阅读:
    局域网中CSMA/CD协议的应用
    RIP及距离向量算法
    网桥与以太网交换机
    C++ String
    C++ Input & Output
    Shell Script(1)----variable compare
    python--内建函数(1)
    python--data type
    python--compile
    python--help
  • 原文地址:https://www.cnblogs.com/canyangfeixue/p/2455906.html
Copyright © 2011-2022 走看看