[Stackoverflow] [Progress OpenEdge ABL] How to connect to an ODBC data source from Spring Boot?

Status
Not open for further replies.
R

Ram

Guest
I am developing a Spring Boot application that polls data from a legacy ODBC data source and inserts it into a MS SQL Server database.

enter image description here

I need to connect to DSN that is using Progress OpenEdge driver.

My R&D code to connect to DSN looks like this:

Code:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class JdbcDemo
{
    public static void main(String args[]) throws Exception
    {
        try
        {
            String query = "SELECT Name,Description,Qty,Cost FROM Stock";

            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            Connection con = DriverManager.getConnection("jdbc:odbc:DSN_Name");
            Statement stmt = con.createStatement();
            ResultSet rs = stmt.executeQuery(query);
            while (rs.next())
            {
                String name = rs.getString("Name");
                String desc = rs.getString("Description");
                int qty = rs.getInt("Qty");
                float cost = rs.getFloat("Cost");
                System.out.println(name + ", " + desc + "\t: " + qty + "\t@ $" + cost);
            }
            con.close();
        }
        catch (Exception e)
        {
            System.err.println(e);
        }

    }
}

But it throws java.lang.ClassNotFoundException: sun.jdbc.odbc.JdbcOdbcDriver error when run. I did some Googling and found this is no longer supported. How can then I connect to this ODBC data source? I am using Java 17.

Continue reading...
 
Status
Not open for further replies.
Top