• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Driver is not supporting to retrive primary key

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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;
}
 
reply
    Bookmark Topic Watch Topic
  • New Topic