oracle jdbc url11g jdbc classes12.zip在哪个文件下 ,谢谢

Oracle连接jdbc
一.用odbc-jdbc
在使用windows操作系统的前提下,我们可以不用去下载oracl的jdbc驱动,可以使用jdbc自带的jdbc-odbc桥
具体使用如下:
1.配置odbc,并命名为orcl
2.配置好了之后就可以写代码了.
//这是需要驱动的步骤,如果是使用oracle的驱动就换成OracleDriver
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
//连接数据库,第一个参数是连接的对象,就是obdc名字,第二个是用户名,第三个是密码
DriverManager.getConnection("jdbc:odbc:orcl","lws","123");
//产生一个执行语句
stmt = conn.createStatement();
//执行我们需要的sql语句
stmt.executeQuery(sql);
//获取查询语句
while(rs.next()) {
&System.out.print(rs.getString("BM") +
&System.out.println(rs.getString("XM"));
上面的这几步就是操作数据库的基本步骤,不管是操作什么数据库,都必须有这几步
二.用oracle驱动
如果是通过oracle驱动来实现对数据库的操作,就要比odbc麻烦一些,但是这样的程序就有很好的移植性,可以不考虑操作系统的不同而带来的局限
oracle安装好了之后,他的目录下就自带了一个叫jdbc的文件夹,这就是oracle的jdbc驱动
首先就要设置环境变量:
On Win95/Win98/NT:
& - Add [ORACLE_HOME]\jdbc\lib\classes111.zip
[ORACLE_HOME]\jdbc\lib\nls_charset11.zip to your CLASSPATH.
classes12.zip and nls_charset12.zip if JDK 1.2.x is used.)
& - Make sure [ORACLE_HOME]\bin is in your
如果是使用eclipse,还需要我们进行类库的导入,这里就不说了
下面是代码
These are a few simple things that you should do in your JDBC
&1. Import the necessary JDBC
classes in your programs that use JDBC.
import java.sql.*;
import java.math.*;
&2. Register the Oracle
driver before before calling other JDBC APIs.
&&& (This is not
needed if you are using the JDBC Server-side Internal
&&& Driver
because registration is done automatically in the server.)
&&& To register
the Oracle driver, make sure the following statement
&&& is executed
at least once in your Java session:
DriverManager.registerDriver(
new oracle.jdbc.OracleDriver());
&3. Open a connection to the
database with the getConnection call.
&&& Different
connection URLs should be used for different JDBC
drivers.& The following examples demonstrate the
different URLs.
the JDBC OCI Driver:
Connection conn = DriverManager.getConnection(
&&&&&&&&&&&&&&&&&&&&&&&&&
"jdbc:oracle:oci:@&database&",
&&&&&&&&&&&&&&&&&&&&&&&&&
"my_user", "my_password");
where &database& is either an entry in tnsnames.ora or a
name-value pair.
the JDBC Thin Driver, or Server-side Thin Driver:
Connection conn = DriverManager.getConnection(
&&&&&&&&&&&&&&&&&&&&&&&&&
"jdbc:oracle:thin:@&database&",
&&&&&&&&&&&&&&&&&&&&&&&&&
"my_user", "my_password");
where &database& is either a string of the form
&host&:&port&:&sid& or a SQL*net name-value
the JDBC Server-side Internal Driver:
Connection conn = DriverManager.getConnection(
&&&&&&&&&&&&&&&&&&&&&&&&&
"jdbc:oracle:kprb:");
Note that the trailing ':' character is
necessary.& When you use
the Server-side Internal Driver, you always connect to the
database you are executing in.& You can also do
Connection conn
oracle.jdbc.OracleDriver().defaultConnection();
以上网友发言只代表其个人观点,不代表新浪网的观点或立场。温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!&&|&&
喜欢PX的男孩
LOFTER精选
阅读(1003)|
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
历史上的今天
id:'fks_',
blogTitle:'ORACLE的JDBC连接方式:OCI和THIN',
blogAbstract:'oracle的jdbc连接方式',
blogTag:'',
blogUrl:'blog/static/',
isPublished:1,
istop:false,
modifyTime:0,
publishTime:5,
permalink:'blog/static/',
commentCount:0,
mainCommentCount:0,
recommendCount:0,
bsrk:-100,
publisherId:0,
recomBlogHome:false,
currentRecomBlog:false,
attachmentsFileIds:[],
groupInfo:{},
friendstatus:'none',
followstatus:'unFollow',
pubSucc:'',
visitorProvince:'',
visitorCity:'',
visitorNewUser:false,
postAddInfo:{},
mset:'000',
remindgoodnightblog:false,
isBlackVisitor:false,
isShowYodaoAd:false,
hostIntro:'喜欢PX的男孩',
hmcon:'1',
selfRecomBlogCount:'0',
lofter_single:''
{list a as x}
{if x.moveFrom=='wap'}
{elseif x.moveFrom=='iphone'}
{elseif x.moveFrom=='android'}
{elseif x.moveFrom=='mobile'}
${a.selfIntro|escape}{if great260}${suplement}{/if}
{list a as x}
推荐过这篇日志的人:
{list a as x}
{if !!b&&b.length>0}
他们还推荐了:
{list b as y}
转载记录:
{list d as x}
{list a as x}
{list a as x}
{list a as x}
{list a as x}
{if x_index>4}{break}{/if}
${fn2(x.publishTime,'yyyy-MM-dd HH:mm:ss')}
{list a as x}
{if !!(blogDetail.preBlogPermalink)}
{if !!(blogDetail.nextBlogPermalink)}
{list a as x}
{if defined('newslist')&&newslist.length>0}
{list newslist as x}
{if x_index>7}{break}{/if}
{list a as x}
{var first_option =}
{list x.voteDetailList as voteToOption}
{if voteToOption==1}
{if first_option==false},{/if}&&“${b[voteToOption_index]}”&&
{if (x.role!="-1") },“我是${c[x.role]}”&&{/if}
&&&&&&&&${fn1(x.voteTime)}
{if x.userName==''}{/if}
网易公司版权所有&&
{list x.l as y}
{if defined('wl')}
{list wl as x}{/list}

我要回帖

更多关于 oracle jdbc url 的文章

 

随机推荐