Reputation: 38
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!!
Upvotes: 0
Views: 2417
Reputation: 17839
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
Upvotes: 0
Reputation: 6738
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();
Upvotes: 1