I have an account, password and the URL.
-
2What is a web based database?Pascal Thivent– Pascal Thivent2009-11-24 22:37:21 +00:00Commented Nov 24, 2009 at 22:37
-
Sorry its just a server based database, you access it through a web browser. im just unfamiliar with database programing.Mo.– Mo.2009-11-24 23:15:50 +00:00Commented Nov 24, 2009 at 23:15
-
@Mo: Oracle JDBC downloads: oracle.com/technology/software/tech/java/sqlj_jdbc/index.htmlOMG Ponies– OMG Ponies2009-11-24 23:25:57 +00:00Commented Nov 24, 2009 at 23:25
2 Answers
Use:
Connection connection = null;
try {
// Load the JDBC driver
String driverName = "oracle.jdbc.driver.OracleDriver";
Class.forName(driverName);
// Create a connection to the database
String serverName = "127.0.0.1";
String portNumber = "1521";
String sid = "mydatabase";
String url = "jdbc:oracle:thin:@" + serverName + ":" + portNumber + ":" + sid;
String username = "username";
String password = "password";
connection = DriverManager.getConnection(url, username, password);
} catch (ClassNotFoundException e) {
// Could not find the database driver
} catch (SQLException e) {
// Could not connect to the database
}
Reference: Connecting to an Oracle Database
Comments
Just an addendum to OMG Ponies' answer, you will need a couple of items to proceed:
1. A JDBC driver for Oracle on your build path (Oracle offers these drivers for download)
2. The driverName variable in OMG Ponies' code has to be changed to the name of the specific Oracle driver you're using
3. The serverName variable in OMG Ponies' code should NOT be left at 127.0.0.1 but should instead be changed to the server address you mentioned. I only note this because the way you phrased your question implies an unfamiliarity with computer concepts in general and using databases with Java in particular.