Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Driver is not supporting to retrive primary key

 
prakash narkodu
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i use odbc jdbc driver in my project to retrive database from sql server as well as access. I sucessfully retrived database tables but not retriving primary key. it shows error "driver not supported this funciton".So jdbc dbc driver supported these function if it is not then which driver I can use.
folling is the function that I am using in my program.

public Vector gettingPrimaryKey(String strDbUrl1,String strDbName1, String strLogin,String strPwd,String strTable)
{
String s;
String strUsr2;
Vector vecPkCol=new Vector();
if(strDataBaseType.equalsIgnoreCase("Oracle 8i"))
{
s=null;
String strUsr1=strLogin;
strUsr2= strUsr1.toUpperCase();
}
else
{
s = strDbName1;
strUsr2="dbo";
}
String t = null;
String u = null;
String[] vt = {"TABLE"};
try
{
Class.forName(strDriver);
Connection con = DriverManager.getConnection (strDbUrl1,strLogin, strPwd);
Statement stmt1=con.createStatement();
DatabaseMetaData db = con.getMetaData();
ResultSet rs = db.getTables(s,t,u,vt);
ResultSet rsPrimaryKey = db.getPrimaryKeys(s, null, strTable);
while (rsPrimaryKey.next())
{
strPkColumnName=rsPrimaryKey.getString("COLUMN_NAME");
String strPkColName=strTable+"."+strPkColumnName;
vecPkCol.add(strPkColName);
iPkColCount++;
}
rsPrimaryKey.close();
} catch(Exception se)
{
System.out.println(se);
}
return vecPkCol;
}
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic