Skip to main content

[archive] How to read AcuCOBOL vision files from java using AcuODBC

  • November 30, 2010
  • 5 replies
  • 1 view

[Migrated content. Thread originally posted on 24 November 2010]

Hi All,

I am trying to access AcuCOBOL vision files from java using AcuODBC. I am using AcuBench 6.2. My files are in a Unix Server.

I have successfully created DSN using srvconfig.sh script.

And I tried the following java code.


import java.net.URL;
import java.sql.*;

class JDBCapp {

static Connection theConn;

public static void main (String args[]) {
try {
theConn = MyConnection.getConnection();

ResultSet rs;
Statement stmt;
String sql;

sql = "select * from t_invstk";
stmt = theConn.createStatement();
rs = stmt.executeQuery(sql);

while (rs.next()) {
System.out.println(rs.getString(2));
}
rs.close();
stmt.close();
}
catch (Exception e) {
e.printStackTrace();
}
finally {
try {
if (theConn != null) theConn.close();
}
catch (Exception e) {
}
}

}
}

class MyConnection {
public static Connection getConnection() throws Exception {
Driver d = (Driver)Class.forName
("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
/*
Connection c = DriverManager.getConnection(
"jdbc:odbc:Driver={AcuODBC Driver};DBQ=/IMOSDATA/XFD;"
);
return c;
*/
// To use an already defined ODBC Datasource :

Connection c = null;
String URL = "jdbc: odbc: DSN";
try
{
c = DriverManager.getConnection(URL, "user", "pwd"); }
catch (Exception ex)
{
ex.printStackTrace();
System.out.println(ex.getMessage());
}
return c;
}
}


But I unable to establish the connection with the data source.

Please help. Thanks.

--Mano

5 replies

[Migrated content. Thread originally posted on 24 November 2010]

Hi All,

I am trying to access AcuCOBOL vision files from java using AcuODBC. I am using AcuBench 6.2. My files are in a Unix Server.

I have successfully created DSN using srvconfig.sh script.

And I tried the following java code.


import java.net.URL;
import java.sql.*;

class JDBCapp {

static Connection theConn;

public static void main (String args[]) {
try {
theConn = MyConnection.getConnection();

ResultSet rs;
Statement stmt;
String sql;

sql = "select * from t_invstk";
stmt = theConn.createStatement();
rs = stmt.executeQuery(sql);

while (rs.next()) {
System.out.println(rs.getString(2));
}
rs.close();
stmt.close();
}
catch (Exception e) {
e.printStackTrace();
}
finally {
try {
if (theConn != null) theConn.close();
}
catch (Exception e) {
}
}

}
}

class MyConnection {
public static Connection getConnection() throws Exception {
Driver d = (Driver)Class.forName
("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
/*
Connection c = DriverManager.getConnection(
"jdbc:odbc:Driver={AcuODBC Driver};DBQ=/IMOSDATA/XFD;"
);
return c;
*/
// To use an already defined ODBC Datasource :

Connection c = null;
String URL = "jdbc: odbc: DSN";
try
{
c = DriverManager.getConnection(URL, "user", "pwd"); }
catch (Exception ex)
{
ex.printStackTrace();
System.out.println(ex.getMessage());
}
return c;
}
}


But I unable to establish the connection with the data source.

Please help. Thanks.

--Mano
Version 6.2 of AcuODBC does not support Java. You will need to get a more current version (7.4 or later) of Acu XDBC. Acu XDBC Enterperprise supports accessing Vision data via Java.

[Migrated content. Thread originally posted on 24 November 2010]

Hi All,

I am trying to access AcuCOBOL vision files from java using AcuODBC. I am using AcuBench 6.2. My files are in a Unix Server.

I have successfully created DSN using srvconfig.sh script.

And I tried the following java code.


import java.net.URL;
import java.sql.*;

class JDBCapp {

static Connection theConn;

public static void main (String args[]) {
try {
theConn = MyConnection.getConnection();

ResultSet rs;
Statement stmt;
String sql;

sql = "select * from t_invstk";
stmt = theConn.createStatement();
rs = stmt.executeQuery(sql);

while (rs.next()) {
System.out.println(rs.getString(2));
}
rs.close();
stmt.close();
}
catch (Exception e) {
e.printStackTrace();
}
finally {
try {
if (theConn != null) theConn.close();
}
catch (Exception e) {
}
}

}
}

class MyConnection {
public static Connection getConnection() throws Exception {
Driver d = (Driver)Class.forName
("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
/*
Connection c = DriverManager.getConnection(
"jdbc:odbc:Driver={AcuODBC Driver};DBQ=/IMOSDATA/XFD;"
);
return c;
*/
// To use an already defined ODBC Datasource :

Connection c = null;
String URL = "jdbc: odbc: DSN";
try
{
c = DriverManager.getConnection(URL, "user", "pwd"); }
catch (Exception ex)
{
ex.printStackTrace();
System.out.println(ex.getMessage());
}
return c;
}
}


But I unable to establish the connection with the data source.

Please help. Thanks.

--Mano
We did try this at one point, but ended up writing a query tool in Java which talks directly to the Vision data files, so performs a lot faster. We do, however, have a particular function which may require Java to call AcuXDBC, so if you do resolve the issue please post it. Thanks

[Migrated content. Thread originally posted on 24 November 2010]

Hi All,

I am trying to access AcuCOBOL vision files from java using AcuODBC. I am using AcuBench 6.2. My files are in a Unix Server.

I have successfully created DSN using srvconfig.sh script.

And I tried the following java code.


import java.net.URL;
import java.sql.*;

class JDBCapp {

static Connection theConn;

public static void main (String args[]) {
try {
theConn = MyConnection.getConnection();

ResultSet rs;
Statement stmt;
String sql;

sql = "select * from t_invstk";
stmt = theConn.createStatement();
rs = stmt.executeQuery(sql);

while (rs.next()) {
System.out.println(rs.getString(2));
}
rs.close();
stmt.close();
}
catch (Exception e) {
e.printStackTrace();
}
finally {
try {
if (theConn != null) theConn.close();
}
catch (Exception e) {
}
}

}
}

class MyConnection {
public static Connection getConnection() throws Exception {
Driver d = (Driver)Class.forName
("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
/*
Connection c = DriverManager.getConnection(
"jdbc:odbc:Driver={AcuODBC Driver};DBQ=/IMOSDATA/XFD;"
);
return c;
*/
// To use an already defined ODBC Datasource :

Connection c = null;
String URL = "jdbc: odbc: DSN";
try
{
c = DriverManager.getConnection(URL, "user", "pwd"); }
catch (Exception ex)
{
ex.printStackTrace();
System.out.println(ex.getMessage());
}
return c;
}
}


But I unable to establish the connection with the data source.

Please help. Thanks.

--Mano
We did try this at one point, but ended up writing a query tool in Java which talks directly to the Vision data files, so performs a lot faster. We do, however, have a particular function which may require Java to call AcuXDBC, so if you do resolve the issue please post it. Thanks

[Migrated content. Thread originally posted on 24 November 2010]

Hi All,

I am trying to access AcuCOBOL vision files from java using AcuODBC. I am using AcuBench 6.2. My files are in a Unix Server.

I have successfully created DSN using srvconfig.sh script.

And I tried the following java code.


import java.net.URL;
import java.sql.*;

class JDBCapp {

static Connection theConn;

public static void main (String args[]) {
try {
theConn = MyConnection.getConnection();

ResultSet rs;
Statement stmt;
String sql;

sql = "select * from t_invstk";
stmt = theConn.createStatement();
rs = stmt.executeQuery(sql);

while (rs.next()) {
System.out.println(rs.getString(2));
}
rs.close();
stmt.close();
}
catch (Exception e) {
e.printStackTrace();
}
finally {
try {
if (theConn != null) theConn.close();
}
catch (Exception e) {
}
}

}
}

class MyConnection {
public static Connection getConnection() throws Exception {
Driver d = (Driver)Class.forName
("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
/*
Connection c = DriverManager.getConnection(
"jdbc:odbc:Driver={AcuODBC Driver};DBQ=/IMOSDATA/XFD;"
);
return c;
*/
// To use an already defined ODBC Datasource :

Connection c = null;
String URL = "jdbc: odbc: DSN";
try
{
c = DriverManager.getConnection(URL, "user", "pwd"); }
catch (Exception ex)
{
ex.printStackTrace();
System.out.println(ex.getMessage());
}
return c;
}
}


But I unable to establish the connection with the data source.

Please help. Thanks.

--Mano
We did try this at one point, but ended up writing a query tool in Java which talks directly to the Vision data files, so performs a lot faster. We do, however, have a particular function which may require Java to call AcuXDBC, so if you do resolve the issue please post it. Thanks

[Migrated content. Thread originally posted on 24 November 2010]

Hi All,

I am trying to access AcuCOBOL vision files from java using AcuODBC. I am using AcuBench 6.2. My files are in a Unix Server.

I have successfully created DSN using srvconfig.sh script.

And I tried the following java code.


import java.net.URL;
import java.sql.*;

class JDBCapp {

static Connection theConn;

public static void main (String args[]) {
try {
theConn = MyConnection.getConnection();

ResultSet rs;
Statement stmt;
String sql;

sql = "select * from t_invstk";
stmt = theConn.createStatement();
rs = stmt.executeQuery(sql);

while (rs.next()) {
System.out.println(rs.getString(2));
}
rs.close();
stmt.close();
}
catch (Exception e) {
e.printStackTrace();
}
finally {
try {
if (theConn != null) theConn.close();
}
catch (Exception e) {
}
}

}
}

class MyConnection {
public static Connection getConnection() throws Exception {
Driver d = (Driver)Class.forName
("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
/*
Connection c = DriverManager.getConnection(
"jdbc:odbc:Driver={AcuODBC Driver};DBQ=/IMOSDATA/XFD;"
);
return c;
*/
// To use an already defined ODBC Datasource :

Connection c = null;
String URL = "jdbc: odbc: DSN";
try
{
c = DriverManager.getConnection(URL, "user", "pwd"); }
catch (Exception ex)
{
ex.printStackTrace();
System.out.println(ex.getMessage());
}
return c;
}
}


But I unable to establish the connection with the data source.

Please help. Thanks.

--Mano
Thanks for your help ...

I dropped AcuODBC idea to access vision files from java. And, I am now working on creating a COBOL interface to access a vision file using I$IO routine. This COBOL program will act as an interface to perform the File IO operation from java.

Actually i tried using I$IO routine from java.. But I can't find a way to access this library. Also the speed is almost similar to AcuCOBOL (10000 reads per second).

-- Mano