Article View: cn.bbs.comp.database
Article #966Re: ����̡�oracle�����ַ������
From: Kobe
Date: Wed, 10 Sep 2008 13:14
Date: Wed, 10 Sep 2008 13:14
100 lines
3039 bytes
3039 bytes
��.net ��java��Դ���....
OracleConnection.cs
using (OracleConnection conn = new OracleConnection("Password=tiger;User ID=
scott;Persist Security Info=True"))
{
conn.Open();
IDbCommand command = conn.CreateCommand();
command.CommandType = CommandType.Text;
command.CommandText = "select * from A";
IDataReader reader = command.ExecuteReader();
while (reader.Read())
{
// ����ȷ��ȡ��A�е��������
Console.WriteLine(reader.GetValue(0));
Console.WriteLine(reader.GetValue(1));
}
}
}
OracleConnection.java
public static void main(String[] args) {
try {
Connection conn = null;
Statement stmt;
ResultSet rs;
String sql = "select * from A ";
// ����Oracle��ݿ�
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
/*
* conn = DriverManager.getConnection(
* "jdbc:oracle:thin:@localhost:1521:ORCL", "scott", "tiger");
*/
String url = "jdbc:oracle:thin:@localhost:1522:orcl";
String username = "scott";
String password = "tiger";
conn = DriverManager.getConnection(url, username, password); //��
����ôҲ
������.
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
System.out.println(rs.getInt(0));
rs.close();
stmt.close();
conn.close();
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
�� �� shaqlala (Kobe) �Ĵ�������
��: ��: CAS��ɶ��
: �� �� Dem (Galaxy��VOLUNTEERS) �Ĵ������ᵽ: ��
: : ������Ҫע��CAS
--
[m[1;31m�� ��Դ:����ˮ˼Դ bbs.sjtu.edu.cn��[FROM: 219.228.113.137][m
Technical Details
Message-ID:
<4c12SJ$aCb@bbs.sjtu.edu.cn>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!news.cn99.com!newsgate.cuhk.edu.hk!news.neu.edu.cn!news.shec6.edu.cn!SJTUShow Full Headers
Complete Article Headers
X-Google-Thread: 101948,28f39abc5eb8f1d2 X-Google-Attributes: gid101948,domainid0,public,usenet X-Google-Language: ENGLISH,GB Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!news.cn99.com!newsgate.cuhk.edu.hk!news.neu.edu.cn!news.shec6.edu.cn!SJTU From: shaqlala.bbs@bbs.sjtu.edu.cn (Kobe) Newsgroups: cn.bbs.comp.database Subject: Re: ����̡�oracle�����ַ������ Date: 10 Sep 2008 13:14:16 GMT Organization: ��ˮ˼Դ Message-ID: <4c12SJ$aCb@bbs.sjtu.edu.cn> Mime-Version: 1.0 Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: 8bit X-Filename: database/M.1221052243.A Lines: 100