0% found this document useful (0 votes)
153 views5 pages

Advanced Java JDBC Setup Guide

This document provides instructions for setting up a Java development environment for working with JDBC and connecting to an Oracle database. It describes downloading required software like the JDK, Eclipse, and an Oracle JDBC driver jar. It then explains how to create a new Java project in Eclipse, add the JDBC jar to the build path, and write sample code to connect to an Oracle database and print "done" when connected.

Uploaded by

chanty android
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
153 views5 pages

Advanced Java JDBC Setup Guide

This document provides instructions for setting up a Java development environment for working with JDBC and connecting to an Oracle database. It describes downloading required software like the JDK, Eclipse, and an Oracle JDBC driver jar. It then explains how to create a new Java project in Eclipse, add the JDBC jar to the build path, and write sample code to connect to an Oracle database and print "done" when connected.

Uploaded by

chanty android
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Raghu Sir Sathya Technologies, Ameerpet, HYD

Adv Java JDBC Notes -2


*) Software Required
a. JDK 8:
https://www.oracle.com/technetwork/java/javase/downloads/
jdk8-downloads-2133151.html
b. STS/Eclipse Photon
STS 32 bit:
https://download.springsource.com/release/STS/3.9.6.RELEASE
/dist/e4.9/spring-tool-suite-3.9.6.RELEASE-e4.9.0-win32.zip
STS 64 Bit:
https://download.springsource.com/release/STS/3.9.6.RELEASE
/dist/e4.9/spring-tool-suite-3.9.6.RELEASE-e4.9.0-win32-
x86_64.zip
c. Oracle DB 11G **
http://www.mediafire.com/file/e0611q3sq87cm6p/Oracle11Gd
atabase.rar/file
Oracle DB 10G
http://www.mediafire.com/file/roc48z1i6iitpu4/OracleXE.exe/fi
le
------------------------------------
*)Creating new Application in STS/Eclipse
1. Download and Extract STS/Eclipse to
one folder (.zip=> folder)
2. Open folder and find STS.exe or

1
Raghu Sir Sathya Technologies, Ameerpet, HYD

eclipse.exe file (or Application)


double click on this file to start.
3. Choose Workspace(Folder which stores
all our application files)
ex: D:/JdbcExamples
> click on browse for changing location
> finally click on Launch/Start

4. Perspective **: It indicates what


kind of work are we doing in STS/Eclipse
ex: Java Perspective : Core java coding
Java EE Perspective:Advanced and
J2EE coding
Debug Perspective: App Testing
Git Perspective: Update code to
central repository.
5. *** Change to "Java Perspective"
> Window Menu > Perspective option
> Open Perspective > other...
> choose "Java" option. > finish

6 *** If any window or pane is closed,


to get them back use option:
> window > Perspective > Reset Perspective
-----------------------------------------

2
Raghu Sir Sathya Technologies, Ameerpet, HYD

7. Creating Java Project:


> File > New > Java Project
> Enter Project Name
ex: JdbcType2Ex
> Finish button
8. Create Java class under "src" folder
[src means source folder. it should
contain all files of project]
> right click on "src" > new > class
> Enter details:
package : com.app
name : JdbcTest
*** press " ctrl + " or " ctrl - " to
increase and reduce font size.
9. Adding Jars to Project:(Buildpath)
For Oracle 10G use ojdbc14.jar
For Oracle 11G use ojdbc6.jar
> Right click on project name
> choose "Build path"
> Choose "Configure Build path"
> click on Library Tab.
> Click on "Add External Jars" button
> select ojdbc jar > Apply and close.

10. Write code as given before

3
Raghu Sir Sathya Technologies, Ameerpet, HYD

** ctrl+shift+O to get imports


** ctrl+F11 to Run class/get output
** Type main then ctl+space then
enter -> to generate main method

---Sample code--------
package com.app;

import java.sql.Connection;
import java.sql.DriverManager;

public class Test {

public static void main(String[] args)


throws Exception {
//jdbc properties
String
driver="oracle.jdbc.driver.OracleDriver";
String
url="jdbc:oracle:thin:@localhost:1522:ORCL";
String username="system";
String password="admin";

//code
Class.forName(driver);
Connection
con=DriverManager.getConnection(url, username,
password);
System.out.println("done");

4
Raghu Sir Sathya Technologies, Ameerpet, HYD

}
}
=> Run Menu => Run option (ctrl+F11)

FB:
https://www.facebook.com/groups/thejavatemple/
email:
[email protected]

You might also like