whoami
zhu_xianfeng
全部博文(38)
J2SE(9)
J2EE(1)
2011年(1)
2008年(12)
2007年(25)
成都男孩
wyq1986a
shengcha
15295524
helloboy
linux_pl
quanster
cokeboL
jiyin56
分类: Java
2008-03-24 14:39:46
create user michael identified by michael; alter user michael default tablespace sysaux quota 10M on sysaux;
grant create session to michael; grant create table to michael;
create table student ( id number ); insert into student values(2005); insert into student values(2008);
package com.dlut.zxf; import java.sql.*; public class Conn { public static void main(String[] args) { String classDriver = "oracle.jdbc.driver.OracleDriver"; String dbURL = "jdbc:oracle:thin:@localhost:1521:xe"; String user = "michael"; String password = "michael"; String sql = "select id from student"; Connection conn = null; Statement state = null; ResultSet res = null; try { Class.forName(classDriver); } catch (ClassNotFoundException e) { e.printStackTrace(); } try { conn = DriverManager.getConnection(dbURL, user, password); state = conn.createStatement(); res = state.executeQuery(sql); while (res.next()) { System.out.println(res.getString("id")); } } catch (SQLException e) { e.printStackTrace(); } } }
上一篇:JDBC连接池
下一篇:JSP动作组件
登录 注册