Myeclipse connection to Oracle Database detailed tutorial, myeclipseoracle

Source: Internet
Author: User

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 ();}}}

Related Article

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.