Java Reference
In-Depth Information
In the Package Explorer pane, expand Tutorials then Referenced Libraries. If ojdbc6.zip is listed, you have
successfully added the file to the Java Build Path.
We will now define four strings to hold unique Oracle information.
5.
In DBAccess, add the following statement to create a class String variable that holds the
name of the driver:
private String driver = new
String("oracle.jdbc.driver.OracleDriver");
6.
In DBAccess add the following three statements that identify the location of the Oracle
database, as well as the user ID and password to access the database. Then modify the
statements to reflect your information. In other words, in the first statement, substitute
the IP address or URL where Oracle is installed in place of 111.22.333.444. You may have
to change the port (even though 1521 is the default for Oracle); but you will definitely have
to substitute the Oracle System ID for the text SID. In the second and third statements,
change the user ID and password (bjanson and jeter) to your Oracle user ID and password.
private String url = new
String("jdbc:oracle:thin:@ 111.22.333.444 :1521:SID");
private String userid = new String(" bjanson ");
private String pw = new String(" jeter ");
Notice that in the URL, the protocol (jdbc:oracle:thin) is specified before the IP address. In addition, for Oracle,
you must specify a port and SID. As mentioned earlier, each DBMS will have a different protocol name and syntax for
specifying the location of the DBMS.
Tutorial: Accessing a Microsoft Access Database
Microsoft supports a protocol called ODBC (Open Database Connectivity). You must identify the Microsoft Access
Database as an ODBC data source within Windows. This tutorial assumes that a database called TNTDB was created
in Access and has been imported into the project Tutorial
1.
Within Windows 7, click on the Start button, then Control Panel.
2.
On the Control Panel, click on Administrative Tools, then Data Sources (ODBC) (see arrow 1
in Figure 10-5 ). (If you are running 64 bit Windows 7, to see the MS Access driver you will
need to run the following c:\windows\sysWOW64\odbcad32.exe.)
 
Search WWH ::




Custom Search