MyEclipse the method of connecting the newest oracle12c ____oracle

Source: Internet
Author: User

I'm a novice Oracle, I installed Oracle yesterday, I tested it with SQL Plus, all OK, I intend to use Oracle as my common database for Java development. Today, with MyEclipse connection database, there are many problems, the first is classnotfoundexception, on the internet to find Ojdbc14.jar, the result gave me a ora-28040:no matching authentication protocol, and then tried the online said Class12.jar, Class14.jar did not solve the problem, and then another article to see the reason may be the driver version is not correct, you can see in the MANIFAST.MF file as shown in the picture, so load the driver when the CLASS12,CLASS14, And Ojdbc14.jar have deleted, leaving only Ojdbc6.jar, the result is really run successfully, then think of me before in E:\Databases\oracle\product\12.1.0\dbhome_1\NETWORK\ Admin directory under Sqlnet.ora added sqlnet.allowed_logon_version, simply delete this attribute to try, and then restart the Oracle database, the result is no problem, The result is the Ojdbc6.jar file, which is shown in the directory shown in the version is 12, the other is 11 or 10, 9. As for this ojdbc is in E:\Databases\oracle\product\12.1.0\dbhome_1\jdbc\lib, and can only add this one driver, If you add a word with Class.jar at the same time, there will be problems, thus, the problem solved.

I am enclosing a test code that I found on the Internet:

Import java.sql.Connection;
Import Java.sql.DriverManager;
Import java.sql.PreparedStatement;

Import Java.sql.ResultSet;  public class Execute {/** * A very standard example code to connect to an Oracle database */public static void Main (String [] args) {Connection con =
		null;//Create a database connection PreparedStatement pre = null;//Create Precompiled statement objects, usually with this instead of statement ResultSet result = null;//Create a results set object try {class.forname ("oracle.jdbc.driver.OracleDriver");//Load Oracle driver//drivermanager.registerdriver (new ORACLE.J Dbc. 
			Oracledriver ()); System.out.println ("Start trying to connect to the database.")
			");
			String url = "Jdbc:oracle:" + "thin: @localhost: 1521:ORACLEKD";/127.0.0.1 is native address String user = "System";//user name, system default account name String password = "Learning";//You install the password of the selected settings con = drivermanager.getconnection (url, user, password);//Get Connection System. OUT.PRINTLN ("Connection succeeded.")
			"); String sql = "SELECT * from Users where name=?"; /precompiled statement, ". "represents the parameter pre = con.preparestatement (SQL);//Instantiate Precompiled Statement pre.setstring (1," Liu Xianhan ");/set parameter, the preceding 1 represents the index of the parameter, not the index result of the column name in the table Pre.executequery (),//Execute query, note that there is no need to add a parameter while (Result.next ())//When the result set is not empty System.out.println ("School Number:" + result.ge
		TINT ("id") + "Name:" + result.getstring ("name"));
		catch (Exception e) {e.printstacktrace (); Finally {try {///one of the above objects is closed, because not closing affects performance, and resource//attention to the order of shutdown, the last use of the first closed if (result!= null) cause.
				Close ();
				if (pre!= null) Pre.close ();
				if (con!= null) con.close (); SYSTEM.OUT.PRINTLN (The database connection is closed.
			");
			catch (Exception e) {e.printstacktrace ();
 }
		}
	}
}


 

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.