Kbase P120873: How to connect to an OpenEdge database from a java application using a data source?
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  30/11/2006 |
|
Status: Unverified
GOAL:
How to connect to an OpenEdge database from a java application using a data source?
GOAL:
Sample java program to connect to a database using the JDBC driver and a data source.
FACT(s) (Environment):
OpenEdge 10.1x
FIX:
This sample program uses the following connection parameters:
Database: sports2000
Port: 9999
Host: localhost
Username: user
Password: user
/*connect.java*/
import java.sql.*;
import java.io.*;
import java.util.*;
import com.ddtek.jdbcx.openedge.*;
public class connect
{
private Connection con;
public static void main(String argv[]) throws IOException
{
connect session = new connect();
}
public connect() throws IOException
{
try
{
OpenEdgeDataSource oeds = new OpenEdgeDataSource();
oeds.setDatabaseName("sports2000");
oeds.setPortNumber(9999);
oeds.setServerName("localhost");
oeds.setUser("user");
oeds.setPassword("user");
con = oeds.getConnection ();
//Runs a SELECT just to show that the connection is working
Statement stmt = con.createStatement();
ResultSet rset = stmt.executeQuery ("select name from PUB.customer");
while (rset.next())
{
System.out.println(rset.getString(1));
}
//Closes the connection right away.
con.close();
}
&nb.sp; catch (java.lang.Exception ex)
{
ex.printStackTrace();
return;
}
}
}
.