新闻中心> 文章详情

Java连接Oracle11g数据库的过程和步骤

2016年03月15日

  数据库的操作基本是差不多的,比如mysql,Oracle,sqlserve的操作,都是差不多的

 

  第一步都是加载驱动包

 

  第二步是通过连接路径连接数据库

 

  第三步就是操作了。。接下来基本一样

 

  比如Java中连接Oracle11g数据库的过程代码

 

  首先应该要先加载驱动包 找到Oracle 11g安装目录下的路径app\tao\product\11.2.0\dbhome_1\jdbc\lib 的ojdbc6.jar包放到你的工作空间building > private final String NAME="scott";//数据库的名字

 

  private> private Connection conn=null;//连接的对象

 

  private PreparedStatement> private ResultSet rs=null;//查询的对象

 

  /**

 

  * @param> } catch (SQLException e) {

 

  // TODO Auto-generated> try {

 

  pr=conn.prepareStatement("select *> while(rs.next()){//

 

  str=rs.getInt(1)+" ";

 

  str=str+rs.getString(2)+" ";

 

  str=str+rs.getString(3)+" ";

 

  str=str+rs.getString(4)+" ";

 

  str=str+rs.getDate(5)+" ";

 

  str=str+rs.getString(6)+" ";

 

  str=str+rs.getDate(7)+" ";

 

  str=str+rs.getInt(8)+" ";

 

  str=str+rs.getString(9)+" ";

 

  }

 

  }> da.connection();//调用函数操作数据库

 

  }

 

  }

 

  就连接好了Oracle的数据库了,可以操作数据库了。


上一篇下一篇
按时发顺丰

技术交流群

Java大数据交流群560819979    加入
Python技术交流群595083299    加入
Oracle技术交流群595119011    加入
Web前端技术交流群604697610    加入
Huawei技术交流群482919361    加入
Redhat技术交流群587875348    加入
UI设计技术交流群511649801    加入
Cisco技术交流群596886705    加入
IT运维技术交流群605888381    加入