Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Getting primary key information from Pervasive SQL

807591May 14 2008 — edited May 14 2008
I am doing a project in which I have to get the primary key information of a Table at run time. I have to do this task in both SQL Server and Pervasive SQL Databases. I found a function getPrimaryKeys() to do this task. The problem is that this function is giving results in the SQL Server Database but its not giving any result in the Pervasive SQL Database. I have debuged the following code and in case of Pervasive the getPrimaryKeys() method is returning empty ResultSet.

import java.sql.*;

public class Main {

public static void main(String[] args) {


try {

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newI nstance();

Connection db_connection =
DriverManager.getConnection ("jdbc:odbc:MQAUPDT", "", "");
Statement db_statement = db_connection.createStatement();

String tableName = "GPRCCODE";

ResultSet rs = null;

DatabaseMetaData meta = db_connection.getMetaData();
rs = meta.getPrimaryKeys(null, null, tableName);

while (rs.next())
{
System.out.println(rs.getString("COLUMN_NAME"));

}
rs.close();

}

catch (Exception e) {
System.out.println(e.getMessage());
}

}
}

Can anyone tell me that whether this method works for Pervasive or not? And if this method doesn't work with Pervasive then whats the alternate way of doing the same thing.

Waiting for the reply and thanks in advance.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 11 2008
Added on May 14 2008
1 comment
351 views