如何用oracle连接oracle

如何用oracle连接oracle

问题描述:

如何连接oracle与java

how to connect oracle with java

示例1



http://www.exampledepot.com/egs/java.sql/ConnectOracle.html [ ^ ]



例2



http:// www .rgagnon.com / javadetails / java-0112.html [ ^ ]











如何使用Google [ ^ ]
Example 1

http://www.exampledepot.com/egs/java.sql/ConnectOracle.html[^]

Example 2

http://www.rgagnon.com/javadetails/java-0112.html[^]





How to Google[^]


每当您想要连接到任何数据库服务器时必须遵循以下4个步骤:



1.注册驱动程序(Class.forName(driverName)这里oracle驱动程序名称是:

oracle.jdbc.driver.OracleDriver)



2.获取连接(DriverManager.getConnection(url,username,password)这里oracle url是:jdbc:oracle: thin:@+ serverName +:+ portNumber +:+ sid)



3.创建一个语句(Statement smt = con.createStatement())



4.执行查询(可选)



5.关闭连接(con.close( ))



使用那些你可以连接到java中的任何数据库的步骤
whenever you want connect to any database server you have to follow the 4 steps as:

1.Register the driver(Class.forName(driverName) here oracle driver name is :
oracle.jdbc.driver.OracleDriver)

2.Get the connection(DriverManager.getConnection(url, username, password) here oracle url is:"jdbc:oracle:thin:@" + serverName + ":" + portNumber + ":" + sid)

3.Create a statement(Statement smt=con.createStatement())

4.Execute the query(optional)

5.Close the connections(con.close())

using those steps you can connect to any database in java


来连接oracle你必须执行2个步骤

1.建立连接

a。加载驱动程序:Class.forName(sun.jdbc.odbc.JdbcOdbcDriver);

b。建立连接

连接con = DriverManager.connection(jdbc:odbc:< dsnname,>< username>,< password>);

2.执行语句。

语句st = con.createStatement();

st.executeUpdate(create table xyz(no number);



注意:基于驱动程序类型
to connect oracle u have to perform 2 steps
1. Establish connection
a. loading drivers: Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
b. making connection
Connection con=DriverManager.connection("jdbc:odbc:<dsnname","><username>","<password>");
2. executing statements.
Statement st=con.createStatement();
st.executeUpdate("create table xyz(no number);

Note: Based on Type on Driver