Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

SQl exception for using getPrimaryKeys() of DatabaseMetaData

0 views
Skip to first unread message

nasheeda

unread,
Mar 31, 2006, 5:12:07 AM3/31/06
to
Hi,

iam getting runtime error when i use getPrimaryKeys() method. the
following is the code and the sql exception generated.

//////////////////////////////////////////////////////
Program: TestDb.java
public class TestDb {


public static void main(String args[]) {
ResultSet rs=null;
Statement st=null;
Connection con=null;
File instanceFile = new File("C:/Documents and
Settings/snanjum/My Documents/experiment data/BankDB.mdb");
DatabaseMetaData dbMetaData;
String[] a = { "TABLE" };
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(java.lang.ClassNotFoundException cnfe)
{
System.err.print("ClassNotFoundException: ");
System.err.println(cnfe.getMessage());
}
try
{
//con=DriverManager.getConnection("jdbc:odbc:Driver={MicroSoft
Access Driver (*.mdb)};DBQ="+instanceFile.getPath());
con =
DriverManager.getConnection("jdbc:odbc:Database","
"," ");
st=con.createStatement();

dbMetaData = con.getMetaData();
//rs = dbMetaData.getTables(null,null,null,a);
// rs = st.executeQuery("SELECT * FROM Products INNER JOIN
Transactions ON Transactions.custID = Products.custID");

rs = dbMetaData.getPrimaryKeys(null,
"","Products");

if(rs==null)
{
System.out.println("Null object is being returned ");
}



//System.out.println("rs contains
:"+rs.getString(1));
ResultSetMetaData rsmd = rs.getMetaData();
String result0 = "";

while(rs.next())
{
System.out.println("# of columns
:"+rsmd.getColumnCount());
for (int i = 0; i < rsmd.getColumnCount(); i++)

{
System.out.println("iam here in
loop");
result0 += rs.getString(i + 1) +
":";
}

result0 += "\n";
}

System.out.println("----"+result0);
/*

while(rs.next())
{
System.out.println("Primary Key
-"+rs.getString(4));
}*/
}
catch(SQLException sqle)
{
sqle.printStackTrace();
}
catch(Exception e)
{
System.out.println(e);
}
try {
rs.close();
st.close();
con.close();
}
catch(Exception e){ }
}
}

//////////////////////////////////////////////

Runtime Exception Generated:

java.sql.SQLException: [Microsoft][ODBC Driver Manager] Driver does
not support
this function
at
sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6958)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7115)
at sun.jdbc.odbc.JdbcOdbc.SQLPrimaryKeys(JdbcOdbc.java:4917)
at
sun.jdbc.odbc.JdbcOdbcDatabaseMetaData.getPrimaryKeys(JdbcOdbcDatabas
eMetaData.java:2976)
at analysis.TestDb.main(TestDb.java:37)
Press any key to continue...

Thanx in advance.

nasheeda.

zha...@hxtt.com

unread,
Apr 6, 2006, 4:49:46 AM4/6/06
to
>java.sql.SQLException: [Microsoft][ODBC Driver Manager] Driver does not support
>this function
>sun.jdbc.odbc.JdbcOdbcDatabaseMetaData.getPrimaryKeys
free jdbc-odbc bridge driver doesn't support that function, HXTT
Access(http://www.hxtt.com/access.html) supports it but is a commercial
package.

0 new messages