Databases

My Oracle Notes

Here are some quick memos about Oracle. They are mostly here to be a place where I can refresh my memory.

== Start a Oracle databse instance ==

* Setup paths and SID
export ORACLE_HOME=/usr/oracle/Ora901
export PATH=$PATH:$ORACLE_HOME/bin
export ORACLE_SID=mysid

* Start TNS Listner
lsnrctl start

* Startup the instance

$ sqlplus "/ as sysdba"

SQL*Plus: Release 9.2.0.8.0 - Production on Mon Dec 3 11:51:25 2007

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.

Connected to an idle instance.

SQL> startup

JDBCInfo

Here is a small Java application which connects to a database using JDBC and prints some information.


import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;

public class JDBCInfo {
private Connection conn;

public JDBCInfo(String driver, String url) {
if (driver != null) {
try {
Class.forName(driver);
System.out.println("Registered JDBC driver '" + driver + "'");
} catch (ClassNotFoundException e) {