Main Menu

KB#01102-Connecting to Oracle database from BBj

Title:

Connecting to Oracle database from BBj

Description:

The following is a short example that uses the all Java, Thin JDBC driver for Oracle to access data in the sample database installed with Oracle. The example assumes that you have included the classes12.jar file from the Oracle installation in your BBj classpath. Questions about the exact location or usage of the Oracle JDBC driver, consult the Oracle documentation. This article is designed to give general guidelines that can cause problems if you are not aware of the pitfalls. The following code does not require any additions to (or even the existence of) an SQL.ini file. 


0010 java.lang.Class.forName("oracle.jdbc.driver.OracleDriver") 

0020 sqlopen(1,mode="user=myuser,password=mypass")"jdbc:oracle:thin:@//localhost:1521/orcl" 

0030 sqlprep(1)"select * from hr.employees order by last_name, first_name" 

0040 sqlexec(1) 

0050 dim rec$:sqltmpl(1) 

0060 rec$ = sqlfetch(1, err=eof) 

0070 print rec.first_name$ + " " + rec.last_name$ + " - " + rec.phone_number$ 

0080 goto 60 

0090 eof: 

0100 sqlclose(1) 



*** IMPORTANT *** 

The MODE= portion of the connect string is very important with Oracle connections. You must specify user=username, password=yourpassword exactly as documented by Oracle with the key values "user" and "password" being all lowercase. Oracle is case sensitive with it's property key names. Using UID= and PWD= will not work with Oracle data sources. This also applies to any connection specific settings when connecting to Oracle. Use the property names exactly as described in the Oracle documentation. 




Last Modified: 12/28/2005 Product: BBj Operating System: All platforms

BASIS structures five components of their technology into the BBx Generations.

  Google+ View BASIS LinkedIN Profile Visit our Twitter Feed Check out our Facebook Public Profile Click to View the BASIS youTube channel