Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Database/JDBC/SQL/JDO/Hibernate  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 用jdbc连oracle数据库
pqx3318





发贴: 3
积分: 0
于 2006-11-18 13:20 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list

import java.sql.*;

public class HelloJDBC {

public static void main(String[] args) throws ClassNotFoundException, SQLException {
//第一步,建立驱动程序实例
Class.forName("oracle.jdbc.driver.OracleDriver");

//第二步,获得连接
Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:oracle", "system", "pqx3318");

//第三步,获得Statement
Statement stmt = con.createStatement();

String sql = "select id,name from HelloJDBC";

//第四步,执行SQL语句
ResultSet rs = stmt.executeQuery(sql);

//处理结果集
while(rs.next()) {
int id = rs.getInt("id");
String name = rs.getString("name");


System.out.println("id: " + id + ", name: " + name);
}

//第六步s
rs.close();
stmt.close();
con.close();
}

}

用jdbc连oracle数据库
怎么弄咯
要设置环境变量吗
命令行和myeclipse里面分别怎么弄?
上面的程序错对了吗?为什么在我的机器上跑不起
谁能告诉我错在哪咯
谢谢拉


why edited on 2006-11-20 05:55

作者 Re:用jdbc连oracle数据库 [Re:pqx3318]
junyuo





发贴: 95
积分: 0
于 2006-11-19 16:40 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
what kind of error message you get?


OCAJ, SCJP, SCWCD, SCBCD, OCEJPA, OCUP Fundamental, OCA, BEA 8.1 Certified Administrator, IBM Certified SOA Solution Designer
作者 Re:用jdbc连oracle数据库 [Re:pqx3318]
pqx3318





发贴: 3
积分: 0
于 2006-11-19 20:43 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list


(缩略图,点击图片链接看原图)




flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2020 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号
客服电话 0592-8750026    客服信箱 714923@qq.com    客服QQ 714923