This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

database connectivity in visualage for java  RSS feed

rose deng
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to connect a database in visualage for java?
Please shed some ligh on this.
thanks a lot.
Bisi Adedokun
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are two ways to connect to Databases in VAJ: one, you can configure a datasource and use the datasource to connect to the database. Second, you can just use jdbc directly. The first option is mostly useful when you use EJB/WTE in VAJ.
I will provide both methods of connections:
If you are using WTE (WebSphere Test Envieonment):
Lunch WTE
Start the persistent name server
click on datasource
on datasource page provide the following:
Data Source: provide a name (eg myDataSource)
Connection Type: (for DB2)
oracle.jdbc.driver.OracleDriver (for Oracle)
Database URL: jdbc:db2:myDatabaseName (for DB2)
jdbc.url=jdbc racle:thin:@myHostName:1521:myInstanceName (for Oracle)
That is all you need to provide on this page. Then you can go to server configuration, right click and select properties:
on the property page, do the following:
Data Source: myDataSource
Connection Type: <DataSource> (select this from the combo list)
Database User ID: myUserID
Database Password: myPassword
You can accept the default value for the rest of the items on the page.
For direct connect using jdbc, use the following:
String userid = "myUserID";
String passwd = "myPassword";
// Get connection to the database
String url = "jdbc:db2:myDatabaseName"; // for DB2
String url = "jdbc.url=jdbc racle:thin:@myHostName:1521:myInstanceName" // for Oracle
// for DB2
// for Oracle
// get default connection
java.sql.Connection con =
java.sql.DriverManager.getConnection(url, userid, passwd);
I hope this helps.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!