Myeclipse connection to Oracle Database detailed tutorial, myeclipseoracle
With the idea of hard work, I started to play with the database. I used to play with Microsoft's SQL Server. Later, due to the strong compatibility of Oracle Database, the installation is also more friendly than SQL Server (it does not occupy a lot of space on the C disk, and the installation file seems to be a little smaller), and the internship company also uses Oracle, so it decided to switch to Oracle. Here I use Oracle 12c. Write a query function and record the general process for backup.
Install Oracle and create users.
First, open MyEclipse Database Explorer
Create a connection on the left, select the driver, and enter the Oracle address, port number, logon name, and password. You can name the driver by yourself. Note:Ojdbc. jar have to select ojdbc6 or ojdbc7, the existing ojdbc14 cannot be used, there will be a java. SQL. SQLException: ORA-28040: No matching authentication protocol Error prompt.
After the configuration is complete, click Test to Test whether the connection is successful.
You can open the database on the left.
Then in Oracle, create a table and add data (generally, Oracle tables are not created in the program. All Tables are created, fields are defined, and added, deleted, modified, and queried ).
The next step is to create a Java Project to query the Oracle table.
Do not forget to add ojdbc. jar to the Library.
Query the entire table, which is exactly the same as that in Oracle SQL Developer.
Program:
Package Conn_Oracle; import java. SQL. connection; import java. SQL. driverManager; import java. SQL. resultSet; import java. SQL. SQLException; import java. SQL. statement; public class Conn_Oracle {public static void main (String [] args) throws SQLException {// TODO Auto-generated method stub try {// load the driver Class. forName ("oracle. jdbc. oracleDriver "); // obtain the Connection ct = DriverManager. getConnection ("jdbc: oracle: thin :@ localhost: 1521: oracle", UserInfo. user_name, UserInfo. user_pwd); Statement sm = ct. createStatement (); ResultSet rs1_sm.exe cuteQuery ("select * from MyEclipse_Table"); while (rs. next () {System. out. println (rs. getString ("name") + "" + rs. getString ("password");} rs. close (); sm. close (); ct. close ();} catch (ClassNotFoundException e) {// TODO Auto-generated catch block e. printStackTrace ();}}}