CORE

Hello World program in JAVA

//Hello World program in JAVA
class HelloWorld{
 public static void main(String[] args){
 System.out.println("Hello World");
 }
}
OUTPUT:C:\Users\SouravG\Desktop>javac HelloWorld.java
C:\Users\SouravG\Desktop>java HelloWorld
Hello World

https://www.amazon.com/clouddrive/folder/wgD6Zo3tSHWDWOMkew_vGQ/_VIvP3YLSD-c1z2VAVq9cg?_encoding=UTF8&mgh=1&ref=nav_right_Files&sf=1

Connecting to Oracle Database using ojdbc6

1. Download JDBC driver library for Oracle database
2. JDBC database URL for Oracle database
3. Register Oracle JDBC driver
4. Establish connection
5. Example program

1. Go to oracle website and download the ojdbc file http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-112010-090769.html
2. Download the ojdbc.jar file(ojdbc6.jar)
3. In your Eclipse IDE --> In java Project -> Properties -> Java Build Path ->Add Library-> User Library -> User Library -> New -> jdbc(name given) -> Add external jars -> locate the file where you have kept your ojdbc.jar file.
4. follow the program below
package javaDatabase;
import java.sql.*;  
class OracleCon{  
public static void main(String args[]){  
try{  
//step1 load the driver class  
Class.forName("oracle.jdbc.driver.OracleDriver");  
  
//step2 create  the connection object  
Connection con=DriverManager.getConnection(  
"jdbc:oracle:thin:@localhost:1521:orcl","hr","redhat");  
  
//step3 create the statement object  
Statement stmt=con.createStatement();  
  
//step4 execute query  
ResultSet rs=stmt.executeQuery("select * from jobs");  
while(rs.next())  
//select * from tab -- to know the field type
System.out.println(rs.getString(1)+"  "+rs.getString(2)+"  "+rs.getInt(3)+"  "+rs.getInt(4)); 
  
//step5 close the connection object  
con.close();  
  
}catch(Exception e){ System.out.println(e);}  
  
}  
}
OUTPUT
AD_PRES  President  20080  40000
AD_VP  Administration Vice President  15000  30000
AD_ASST  Administration Assistant  3000  6000
FI_MGR  Finance Manager  8200  16000
FI_ACCOUNT  Accountant  4200  9000
AC_MGR  Accounting Manager  8200  16000
AC_ACCOUNT  Public Accountant  4200  9000
SA_MAN  Sales Manager  10000  20080
SA_REP  Sales Representative  6000  12008
PU_MAN  Purchasing Manager  8000  15000
PU_CLERK  Purchasing Clerk  2500  5500
ST_MAN  Stock Manager  5500  8500
ST_CLERK  Stock Clerk  2008  5000
SH_CLERK  Shipping Clerk  2500  5500

 

Java Collections

Collections.jpg

//Hello World program in JAVA 
class HelloWorld{ 
public static void main(String[] args)
{ System.out.println("Hello World"); } }

Leave a comment

Design a site like this with WordPress.com
Get started