In terms of SQL, you can work on the command prompt in other applications like Eclipse. In this post, we are going to look at working with Eclipse.

 

1. Copy the JDBC Driver file for Oracle to the Java installation location (C:\Program Files\Java\jre1.8.0_211\lib\ext). C:\oraclexe\app\oracle\product\11.2.0\server\jdbc\lib\ojdbc6.jar file

2.Copy to C:\Program Files\Java\jre1.8.0_211\lib\ext

3. Set up Oracle Database Integration in Eclipse
From the Project Explorer screen in Eclipse, you can view the JRE System Library
Right click - Properties - Installed JRE button click
jre8 Select and click the Edit button - Click the Add External JAR button
C:\Program Files\Java\jre8\lib\ext\ojdbc6.jar file

4. Re-drive the Eclipse

5. Create a simple Java-Oracle file and test it.

import java.sql.*;

   public class JDBC_Connect02{
   public static void main(String[] args)  {

   /** ORACLE JDBC Driver Test *****************************************/
	String driver = "oracle.jdbc.driver.OracleDriver"; 
	String url = "jdbc:oracle:thin:@127.0.0.1:1521:orcl";
   /*******************************************************************/

   /** My-SQL JDBC Driver *********************************************/
   //	String driver ="com.mysql.jdbc.Driver";
   //	String url = "jdbc:mysql://localhost/academy";
   /*******************************************************************/

       Connection con = null;

       try{

         Class.forName(driver);

   /**   ORACLE에서 Connection 객체 ***********************************/
          con = DriverManager.getConnection(url, "scott", "tiger" );
   /*******************************************************************/


   /**   My-SQL에서 Connection 객체 ***********************************/
   //	  con = DriverManager.getConnection(url, "totoro", "1234" );
   /*******************************************************************/

         System.out.println("Database connection success.");

       } catch(Exception e){
	    	   System.out.println("Database connection failed.");
		   e.printStackTrace();
       } finally{
		try{
		     if( con != null )        
                     con.close();
		   } catch(Exception e){
			System.out.println( e.getMessage( ));  
                                }
      }
    }
  }  

6. If the database connection failure message appears,
C:\oracle\product\11.2.0\db_1\NETWORK\ADMIN folder listener.ora
tnsnames.ora Check the file Host= computer name, Port=1521, etc.

 

Setting on Eclipse

1.window - show view - others - Data Management File - Data Source Explorer -> Open
2.Database Connections - Right click - New - Oracle - (Insert like attached) - save password - "ping succeed"

To create SQL file (Connection has to be on)

  1. Create SQL package
  2. New - others - SQL Development - SQL File - write a file name
  3. Connection profile

4.enter 'select * from tab;' block -> Alt + X to execute *To comment out : --

5. To create the table, write "

create table customer( no number(4) primary key,
name varchar2(20),
email varchar2(20),
tel varchar2(20) );

"

6. Again, block 'select * from tab;' -> Alt + x, and you will see this table.

'DB > Oracle' 카테고리의 다른 글

Oracle) Reserved words  (0) 2022.10.25
Oracle) Structured Query Language(SQL)  (0) 2022.09.03
Oracle) Setting up  (0) 2022.09.01

+ Recent posts