I have downloaded and installed oracle 10g express from internet and it shows as XE. Don't know what it actually means. Now, I have to connect my java program with the database and try creating table and execute queries as I did during my course with SQL server. Please guide me how to create the dsn, connect with database and do all my jdbc related programs now with this oracle 10g. Please let me know the step by step procedure starting from datasource creation till doing coding for jdbc in java... Thank you!!
-
If you had searched on the net, you would have gotten cs.ubc.ca/~ramesh/cpsc304/tutorial/JDBC/jdbc1.html and some other useful links also ...Vikdor– Vikdor2012-08-27 07:09:08 +00:00Commented Aug 27, 2012 at 7:09
-
What is your context? Desktop or web application?MaVRoSCy– MaVRoSCy2012-08-27 07:12:40 +00:00Commented Aug 27, 2012 at 7:12
-
I think you'll find what you need here .. stanford.edu/dept/itss/docs/oracle/10g/java.101/b10979/…Ruwantha– Ruwantha2012-08-27 07:16:24 +00:00Commented Aug 27, 2012 at 7:16
-
See the manual: docs.oracle.com/cd/B19306_01/java.102/b14355/toc.htmuser330315– user3303152012-08-27 07:31:35 +00:00Commented Aug 27, 2012 at 7:31
-
@MaVRoSCy : i just want to connect my standalone java program with the database i have..DKB - user1543439– DKB - user15434392012-08-31 09:20:13 +00:00Commented Aug 31, 2012 at 9:20
2 Answers
You can create oracle datasource like this;
OracleDataSource ds = new OracleDataSource();
ds.setDriverType("thin");
ds.setServerName("yourServerName");
ds.setPortNumber(1521);
ds.setDatabaseName("yourDatabaseName");
ds.setUser("yourUserName");
ds.setPassword("YourPassword");
And you can get connection like this;
Connection conn = ds.getConnection();
Comments
First of all you have to make the JDBC Connector available to your application. To do that download the JDBC connector from oracle ( http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-10201-088211.html ) and place it somewhere accesible by your application.
Secondly you have to use this JDBC to create a connection to the database. There are plenty of examples on SO on how to java code to query the database.
Here is also a nice complete example of what you are looking for : http://www.javaworkspace.com/connectdatabase/connectOracle.do
UPDATE
This is also a nice file to take a look at that shows you exactly what to do step by step http://pdf.coreservlets.com/first-edition/CSAJSP-Chapter18.pdf