• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Oracle Databse XE 11.2 and the JAVA URL

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Naturally I am stuck at the beginning.

I am trying to figure out the URL that I need in my JAVA class.

I am using the free limited version of Oracle Databse XE 11.2

I am reading http://docs.oracle.com/cd/E11882_01/appdev.112/e13995/oracle/jdbc/OracleDriver.html
and am looking at
Where the URL is of the form:
jdbc:oracle:<drivertype>:@<database>

When I was using MySQL this worked fine
String url = "jdbc:mysql://localhost/visualcafe";

based on what I read at http://docs.oracle.com/cd/B25329_01/doc/appdev.102/b25320/getconn.htm#CACGJJFE
down where the heading is Specifying Database URLs
but for Oracle I think I start out with
String url = "jdbc:oracle:
but I have little clue what the 'drivertype' should be. I am guessing thin
and the database? Well I understand you only have one default database with "Oracle Databse XE 11.2" but I am unsure of the name. I am guessing it is XE
but I think I can skip it all together.

If my guesses are correct then I think I need something like this"
String url = "jdbc:oraclel:thin";
or
String url = "jdbc:oraclel:thinRod/testOracle";



And that leads to the connection.
for MySQL this worked
Connection aConnection = DriverManager.getConnection(url, "root", "testmysql");

but for Oracle I am puzzled.
When I went to the 'Get Started with Oracle Database 11g Express Edition'
I created for Database User name 'Rod'
and for the password testOracle

So I don't really know what values I put in here
I am guessing
Connection aConnection = DriverManager.getConnection(url, "Rod", "testOraclel");
or maybe because I am using the Oracel Express 11g I can get away with just
Connection aConnection = DriverManager.getConnection(url");











 
Ranch Hand
Posts: 624
9
BSD Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Creating a connection object would be something like this
where
127.0.0.1: hostname/ip of the machine where Oracle is installed
xe: name of the database you are connecting to
Rod: schema
testOracle: password

Note: Password is case sensitive in Oracle 11g
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think this discussion would fit better into our Oracle forum.
 
Rod Hittle
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So is 127.0.0.1 always the IP address of any PC that Oracle XE is installed on?
 
Tapas Chand
Ranch Hand
Posts: 624
9
BSD Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No.
127.0.0.1 is localhost.
If your Java application is running on the same machine where Oracle is installed then use can use 127.0.0.1 or localhost. Both will do.
If Java application and Oracle are in different machine then you have to mention the hostname of the machine where Oracle is installed.
 
Rod Hittle
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well I finally got it all working.
The values for Hostname and Username and password were all dependent on what I did when I made the connection using SQL DEVELOPER

My choices using Oracle’s SQL Developer
Connection Name: Connection1
Username: Rod
Password: myOracle11
Hostname: localhost
Port: 1521 which is the default value
SID: xe


here is the JAVA code


That was a lot of digging to figure out how to just connect to a table in Oracle 11 Express.
But I got there.
 
Rod Hittle
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
looks like where I tried to BOLD some words in the code did not turn out as I expected.
 
reply
    Bookmark Topic Watch Topic
  • New Topic