Connecting JAVA to Oracle?
Hi Folks...I am an absolute newbie in JAVA....I have Windows Media Centre installed on my machine...Also I have Oracle 10g release 2 for the same....But I haven't installed it(oracle) yet....I have also not installed Java....First and foremost give me the link to download java so that I can run my java programs from Windows Command line...also this version of JAVA should be compatible with Oracle 10g release 2 for Windows.....Actually I want to connect my JAVA to ORACLE using JDBC...I have no idea what so ever on how to achieve it..So can any one please give some online link or resource to use JDBC or suggest some good book for it........
For the JDBC Drvier:
www.oracle.com and search for the newest JDBC Driver
For Java:
java.sun.com and follow the links for JSE (Java 6) and download the JDK (not just the JSE). Then follow the links to the API documentation and bookmark that, then, in that documentation, there is also a link to the Tutorials. Bookmark that, too.
Similar Messages
-
How to connect Java to oracle Database Express Edition?
Anyone can help me?
How to connect JAVA TO ORACLE DATABASE EXPRESS EDITION?I suggest you to read this article:
http://wiki.oracle.com/page/JDBC
Regards,
Ricky -
How to connect java with oracle
can any body show me the code of how to connect java with oracle database.
thank youTo configure Oracle JDBC:
1. Add Oracle JDBC JAR file classes12.zip or ojdbc14.zip to classpath.
2. Load and register the JDBC driver.
Class.forName("oracle.jdbc.driver.OracleDriver");
3. Obtain a connection:
String url="jdbc:oracle:thin:@<host>:1521:<database>
Connection con = DriverManager.getConnection(url,
"myLogin", "myPassword");
4. Create a SQL statement.
Statement stmt = con.createStatement();
5. Obtain a result set.
ResultSet rs = stmt.executeQuery(
"SELECT ..."); -
Unable to connect JAVA with Oracle
I have jdk1.6 and oracle installed on my machine but unable to connect java with database
have classes12.jar and ojdbc14.jar
my environmental variables in respect to this are :
JAVA_HOME= C:\Java\jdk1.6.0_04
JRE_HOME=C:\Java\jdk1.6.0_04
PATH=J:\oracle\ora92\lib;
J:\oracle\ora92\bin;
C:\Program Files\Oracle\jre\1.3.1\bin;
C:\Program Files\Oracle\jre\1.1.8\bin
CLASSPATH=J:\oracle\ora92\jdk\jre\bin\JdbcOdbc.dll;
J:\oracle\ora92\jdbc\lib\classes12.jar;
J:\oracle\ora92\jdbc\lib\ojdbc14.jar
The code is
import java.sql.*; public class dat1 { public static void main(String[] args)throws SQLException,ClassNotFoundException { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Class.forName("com.oracle.jdbc.OracleDriver"); } catch (ClassNotFoundException e) { System.out.println("unable to load driver"); return; } } }
the error message is
Error in thread "main" java.lang.NoClassDefFoundError
Please Help Me
Thanks For Reading
Thanks a lot in Advance For your ANSWERSmaybe if you asked nicely instead of ordering people around we might tell you.
As it is all you're going to hear is that you don't need both those jars, as they contain different versions of the same driver.
I'm not going to tell you which you need, as you should have the documentation to tell you that. But then you also should have the documentation to tell you how to set your classpath properly and you failed to read that too. -
i am new to oracle.
i cant connect java(jdk1.3) to oracle using 'oracle.jdbc.driver.OracleDriver' in Class.forName() and DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","scott","tiger")
it shows "class not found" error.
is there any one to suggest or help me?Hi,
you are posting in wrong forum, as this one is for SQLDeveloper-related issues only. You should post java-related issues in this forum:
SQL Developer
However, about your exception you have missed to put the oracle jdbc driver in the classpath.
Download it from here:
SQL Developer
and see more info here:
http://www.oracle.com/technology/sample_code/tech/java/codesnippet/jdbc/index.html -
Noclassfound error while connecting java with oracle database
hi all
the source code metioned below gets compiled. but when it is run
it gives thefollowing error.
ClassNotFoundException: jdbc.driver.OracleDriver
Exception in thread "main" java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getConnection(DriverManager.java:532)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at pract.main(pract.java:16)
import java.sql.*;
class pract
public static void main (String args []) throws SQLException
try
Class.forName("jdbc.driver.OracleDriver");
catch(java.lang.ClassNotFoundException e)
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
Connection conn = DriverManager.getConnection
("jdbc:oracle:thin:@anant:1521:student", "scott", "tiger");
// @machineName:port:SID, userid, pas
Statement stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery("select * from emp");
while (rset.next())
System.out.println (rset.getString(1)); // Print col 1
stmt.close();
i have included the following driver classes in the classpath
ojdbc.jar,
ojdbc_g.jar,
classes111.jar
but still im unable to connect.
can anyone help me in solving this simple problem.hi ,
you hav not stated which oracle ur using...still if u r using oracle 9i then u hav to include classes12.jar file in ur lib build classpath and then tryout following changes in code....
DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
conn = DriverManager.getConnection("jdbc:oracle:thin:@<host>:<port>:<sid>","scott","tiger");
hope this ll help.... -
Problem connecting java to oracle
new to jdbc so might appear stupid, but i have tried to create a basic connection from a java application to oracle using the following code
Class.forName("oracle.jdbc.driver.OracleDriver") ;}
system.out.println("msg1");
con = DriverManager.getConnection
("jdbc:oracle:thin:@//(local host)","(username)", "(password)");
system.out.println("msg2");
but when i run the application it displays msg1 fine, but then seems to run into a problem because it is contiuously running without carrying out the other commands, and needs to be stopped manually. problem is i done the exact same thing on another computer and works fine. Was wondering if a firewall problem or something, any help would be appreciated.It looks like the connection URL is not complete. Need to specify the database port number and SID (1521, and XE, for example).
The examples in Oracle's JDBC FAQ page:
Connection conn = DriverManager.getConnection
("jdbc:oracle:thin:@//myhost:1521/orcl", "scott", "tiger");
Connection conn = DriverManager.getConnection
("jdbc:oracle:thin:scott/tiger@myhost:1521:orcl);
Link:
http://www.oracle.com/technology/tech/java/sqlj_jdbc/htdocs/jdbc_faq.htm#03_01 -
How to connect java to oracle 9i
Hi guys , i'm still beginner in oracle ,I've created a database and i need to connect a java application to it ,i mention that i'm using netbeans as IDE (tomcat server is embedded with it),please any help.
Ok , I manage to make the connection to my DB using the help of netbeans ,but i'm only able to run sql statement using the sql editor ,but when it comes to creating a class that does the connection and execute sql statement ,the IDE tell me that there is no driver ,but in reality i'm connected to the database,here's the code i've written to access the db:
import java.sql.*;
* @author XPPRESP3
public class Main {
public static void main(String[] args) {
Connection connection = null;
try {
// Load the JDBC driver
String driverName = "oracle.jdbc.driver.OracleDriver";
Class.forName(driverName);
String url=" jdbc:oracle:oci8:@db1";
connection = DriverManager.getConnection(url,"Scott","tiger");
} catch (ClassNotFoundException e) {
System.out.print("no DRIVER ");
} catch (SQLException e) {
System.out.print("no db ");
} -
Ok , I manage to make the connection to my DB using the help of netbeans ,but i'm only able to run sql statement using the sql editor ,but when it comes to creating a class that does the connection and execute sql statement ,the IDE tell me that there is no driver ,but in reality i'm connected to the database,here's the code i've written to access the db:
import java.sql.*;
* @author XPPRESP3
public class Main {
public static void main(String[] args) {
Connection connection = null;
try {
// Load the JDBC driver
String driverName = "oracle.jdbc.driver.OracleDriver";
Class.forName(driverName);
String url=" jdbc:oracle:oci8:@db1";
connection = DriverManager.getConnection(url,"Scott","tiger");
} catch (ClassNotFoundException e) {
System.out.print("no DRIVER ");
} catch (SQLException e) {
System.out.print("no db ");
}Duplicate post:
how to connect java to oracle 9i
(By the way, such a procedure does not accelerate solution of your problem).
Werner -
How to connect java with oracle report server... i m using a swing application.... I have seen api documentation but didnt get things. please help...
user13323568 wrote:
How to connect java with oracle report server... i m using a swing application.... I have seen api documentation but didnt get things. please help...How can anyone help you?
You "don't get things", that is a problem you have to solve before you can be helped. Maybe you just need to spend more time on it or find better documentation; API documentation is only a reference, not a manual. -
Unable to create connection to the Oracle Java Cloud server
Hi All,
I am trying to deploy simple ADF application to Oracle Cloud.
I am successfully transfered HR schema to my database cloud service and now am trying to create a connection to the oracle java cloud service instance
but it is failing to create a connection to the cloud server and throwing the error message
Testing Cloud-Admin ... failed.
listApplications failed.
Check username, password, domain, instance.
Check cloud sdk location & version: Tools->Preferences->Oracle Cloud
0 of 1 tests successful.
MyService details are as follows
JDEV : Build JDEVADF_11.1.1.6.0CLOUD_GENERIC_121118.1600.6229
Cloud version: 13.2.2.0.0
I am pretty sure , i am using proper credentials since am able to java cloud service console with same credentials.
Please help me out on this.
ThanksHi Thanks for the reply
I check check-box of proxy settings and restarted the jdeveloper and tried again but still it throws the same error? one doubt here...what all we need to include / exclude in our proxy settings...
and the I tried providing service name as both java and javatrial8477 but no luck i followed the same steps which are mentioned in the below document
Part 2: Deploying ADF Applications to Oracle Java Cloud
Do i need to do any other configuration? Or i can directly deploy my ear file to java service console rt instead of creating connection tot the server from IDE.
Regards,
Kotresh -
Urgent : Hoe to connect to a ORACLE database throught WEBDYNPRO JAVA
HI All
i am very new to Developer Studio,
i want to connect to an oracle database through wedynpro java.
i have seen some tutorials on SDN. i know something about adding external JARs and OJDBC .
Can anyone send me the sample code to connect to a database
<b>very urgent</b>
Thanks in advance
SushmaHi Sushma
Ask your system Admin for servername,portnumber of database server
Connection conn=null;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
conn =DriverManager.getConnection ("jdbc:oracle:thin:@<servername>:<portnumber>:DB","uname", "pwd");
Statement stmt=conn.createStatement();
ResultSet rs=stmt.executeQuery("select * from <tablename>"); // select statment
while(rs.next())
IXXElement nodeConnection=wdContext.createXXElement(); //creating a node to store the data from oracle
nodeConnection.setYY(rs.getInt("YY")); // setting the values into input fields
nodeConnection.setAA(rs.getInt("AA"));
nodeConnection.setBB(rs.getInt("BB"));
wdContext.nodeXX().addElement(nodeConnection); // adding the node
catch(Exception ex)
finally
try
conn.close(); // closing the connection
catch(Exception e)
welcome to SDN and All the best from SDN Webdynpro JAVA
Regards
Chaitanya.A -
WebDynpro java and Oracle Connection
Hi,
I'm trying to make a simple connection to an Oracle database within a custom webdynpro component. Using NWDS 7.0.08 and EP 7.0 SP 10.
Here is a sample of the java code I use :
Connection conn = null;
Class.forName("oracle.jdbc.driver.OracleDriver");
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
conn =DriverManager.getConnection ("jdbc:oracle:thin:@hostname:port:DATABASENAME","schema", "password");
Statement stmt=conn.createStatement();
ResultSet rs=stmt.executeQuery("select * from MYTABLE");
But when I run this WebDynpro, the following error appears :
"oracle.jdbc.driver.OracleDriver".
I have also catched the exception stack but it doesn't seem meaningful. If you need it, I can provide it in another thread.
So What should I do to connect to this oracle database ? Is it the right provider ?
Thanks,
Loïc LEVEUGLEHi!,
please try following code, this is working fine for me.
String serverName = "172.21.1.62";
String portNumber = "1526";
String sid = "vision";
String url = "jdbc:oracle:thin:@" + serverName + ":" + portNumber + ":" + sid;
String userName = "scott";
String password = "tiger";
Connection connection = null;
try {
// Load the JDBC driver
String driverName = "oracle.jdbc.driver.OracleDriver";
Class.forName(driverName);
connection = DriverManager.getConnection(url, userName, password);
Statement stmt =connection.createStatement();
PreparedStatement pstmt = connection.prepareStatement("insert into club (Name,EmpID,Location,Extention,MailID,InstPlay) values(?,?,?,?,?,?)");
pstmt.clearParameters();
pstmt.setString(1,Name);
pstmt.setString(2,EmpID);
pstmt.setString(3,Location);
pstmt.setString(4,Extention);
pstmt.setString(5,MailID);
pstmt.setString(6,Instrument);
pstmt.executeUpdate();
} catch(Exception exc) {
exc.printStackTrace();
put classes12.jar in your class Path.
regards,
Mithileshwar Sahu -
Webdynpro java and oracle DB connection..
Hi,
I have a good knowledge of WD (web dynpro java) projects having ECC as backend as i have done lot of projects where ECC is backend and WD JAVA is front end.
but in my new project i have wd java as front end but my backend is oracle DB. I want to know how to create/setup connection betwen webdynpro java and oracle DB, how to proceed on this ? wat all settings I have to do in VA (visual admin) and all.
please let me know how to proceed on this. Any document/tutorial on this will be very helpful..Hi Rahul,
Create a DataSource to the oracle db in Visual Admin, give the datasource an alias name and connect to the db from WebDynpro by calling the alias name.
These document might be useful:
[http://help.sap.com/saphelp_nw70/helpdata/en/c0/3ad4d5cdc66447a188b582aad537d3/frameset.htm]
[SAP Note 867176|https://websmp130.sap-ag.de/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/sapnotes/index2.htm?numm=867176]
[SAP Note 941594|https://websmp130.sap-ag.de/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/sapnotes/index2.htm?numm=0000941594&nlang=E]
Good luck!
Regards,
Aditya -
Connecting java apps to Personal Oracle 8.0.3
I would like to find out exactly what driver to use in order to connect Java to Personal Oracle installed on my PC.
this version of the product has been out of support for over a year.
you need to move to the current version which can be located at the "download" site on the technet home page.
Maybe you are looking for
-
Runtime error while AttachPathAndPropagateNotifications()
Hi! I am trying for "replace <column>" expression in a "Derived Column" transformation operator(programatically). Before this, I tried this through SSIS Business Intelligent Studio and it worked! So, I moved towards programatical approach. In my prog
-
IPad on the Enterprise network
Hello All - I am looking to get some more information on the iPad in the enterprise. We are currently using Cisco wireless running a corporate SSID using WPA+WPA2 with AES and 802.1X. Is anyone running iPad's in the 802.1X enterprise? We use a Device
-
I find that my contacts on my Mac book Pro, iPhone 4s, and iPad2 are double or triple listed. I have used time machine to restore a clean set of contacts, but the cloud keep adding double and triple listings of contacts, making more of a mess that I
-
FF5 pointer now circle with a dot in it
Since I loaded FF5 my pointer, for part of the screen, has become a strange little circle with a dot in it. Other parts of the screen it the usual pointer. Anyone else have this "problem?" It only appears such in FF5, and not all of the time or over
-
I was too optimistic... but still no sign of being able to email an image file as attachment! This is what receivers see!!!