Implementation of Oracle over a bridge connection

Source: Internet
Author: User

Package com. Oracle. ConnTest;
Import java. SQL. Connection;
Import java. SQL. DriverManager;
Import java. SQL. ResultSet;
Import java. SQL. SQLException;
Import java. SQL. Statement;
/**
* Oracle connected to the bridge
* @ Author jll
*/
Public class ResConn {
Public static void main (String [] args) throws SQLException {
ResultSet rs = null;
Connection ct = null;
Try {
 /**
* In the data source ODBC user DSN of the management tool on the control panel, add a connection Driver Name MyOracle
* Select the database created by some users in the current data.
*/

Class. forName ("Sun. jdbc. odbc. JdbcOdbcDriver");// Driver Configuration
Ct = DriverManager. getConnection ("Jdbc: odbc: MyOracle "," scott ",
"123");// Scott is the Login User Name. 123 is the password.
Statement st = ct. createStatement ();
Rs = st.exe cuteQuery ("Select * from emp");
While (rs. next ()){
/*
* The number of getString parentheses is determined based on the column fields in the oracle table, and starts from 1.
*/
System. out. println ("username:" + rs. getString (2 ));
System. out. println ("Employee Salary:" + rs. getString (6 ));
System. out. println ("");
}
} Catch (Exception e ){
E. printStackTrace ();
} Finally {
/**
* Close the data source
*/
Rs. close ();
Ct. close ();
}
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.