📗
Notes
  • Introduction
  • Files
  • Android
    • Http
      • Http基础
      • Okhttp理解
    • Jetpack
      • Notes
  • Java ways
    • 101
      • Basis
        • Index
        • Front
          • Angular
            • Angular start 01
            • Angular start 02
          • Typescript
            • Index
            • Ts 01
        • Java
          • Concurrency
          • Frameworks
            • Jdbc与连接池
            • Rxjava基础
            • Spring框架基础
          • Sugar&skill
        • Tool
          • Docker
            • Docker basis
            • Kubernetes play
          • Git
            • Git basic
          • Vim
            • Vim advance
      • Cs
        • Imp
          • Lru
          • Index
    • Snippets
      • Jpa和spring系列注解表
      • Java与oracle数据库各种操作
      • Maven初始化template
      • Nginx配置
      • Nginx反代后配置自动ssl续签
      • 终端033颜色
    • Ways
      • Java ways 01
      • Interview
        • Question
        • Requirements
      • Leetcode101
        • Acwing
          • Index
          • 背包问题
        • Explores
        • Solutions
          • Algorithms
            • Index
          • Concurrency
            • Index
          • Shell
            • Index
          • Sql
            • Index
  • Leecode
    • 牛客
      • 剑指offer
  • Play
    • Youtube离线下载
  • Python basic notes
    • Python days
Powered by GitBook
On this page
  • Java与Oracle数据库各种操作
  • 链接数据库
  • 相关链接

Was this helpful?

  1. Java ways
  2. Snippets

Java与oracle数据库各种操作

   Author: Gentleman.Hu
   Create Time: 2020-09-25 10:42:34
   Modified by: Gentleman.Hu
   Modified time: 2020-09-25 19:14:58
   Email: justfeelingme@gmail.com
   Home: https://crushing.xyz
   Description:

Java与Oracle数据库各种操作

链接数据库

//step1 load the driver class  
Class.forName("oracle.jdbc.driver.OracleDriver");  

//step2 create  the connection object  
Connection con=DriverManager.getConnection(  
"jdbc:oracle:thin:@localhost:1521:xe","system","oracle");  

//step3 create the statement object  
Statement stmt=con.createStatement();  

//step4 execute query  
ResultSet rs=stmt.executeQuery("select * from emp");  
while(rs.next())  
System.out.println(rs.getInt(1)+"  "+rs.getString(2)+"  "+rs.getString(3));  

//step5 close the connection object  
con.close();
  1. 加载drive类

  2. 建立连接

  3. 通过Connection创建Statement对象

  4. 建立ResultSet对象以接受Statement执行的query结果

  5. 关闭连接

相关链接

PreviousJpa和spring系列注解表NextMaven初始化template

Last updated 4 years ago

Was this helpful?

Java Database Connectivity
Official Guide