problem in using DatabaseMetaData getColumns()

Поиск
Список
Период
Сортировка
Искать

problem in using DatabaseMetaData getColumns()

От:
arun vc <vcarun@yahoo.co.uk>
Дата:
hello 

i am getting error while using uisng
dmd.getColumns(null,null,MY_TABLE_NAME,null); 
i am gtting error while using the new pgjdbc2.jar
driver with the old driver postgresql.jar this method
is working .can you help me in solving this problem.
i am sending a sample code


import java.sql.DatabaseMetaData;
import java.sql.SQLException;
import java.sql.ResultSet;	

class CheckDB
{
public static void main(String args[])throws
Exception{
	
String MY_TABLE_NAME="computers";
Connection con;

	try
	{

		Class.forName("org.postgresql.Driver");
		con =
DriverManager.getConnection(jdbc:postgresql://localhost/mytab,loginname,password);
		
		DatabaseMetaData dmd = con.getMetaData();
		String[] tableType = {"TABLE"};  

		ResultSet rs = dmd.getTables(null, null, null,
tableType);

		while ( rs.next() )
		{
			if(MY_TABLE_NAME.equals(rs.getString( "TABLE_NAME"
)))
				System.out.println(MY_TABLE_NAME +" found in
database " ) ;
		}
		rs.close();
				
		rs = dmd.getColumns(null,null,MY_TABLE_NAME,null); 
		// when i try to use
getColumns(null,null,MY_TABLE_NAME,null); method
		// i am getting exception :ERROR:  parser: parse
error at or near "("
		// i am gtting this error while using the new
pgjdbc2.jar Driver
		// with the old driver postgresql.jar this method is
working 

		while(rs.next()) 
		{	
		 colNames[totalFields]=rs.getString( "COLUMN_NAME"
);//here COLUMN_NAME is a key word
		 System.out.println("COLUMN_NAME : " + 
colNames[totalFields]);
		}
		rs.close();
		
	}
	catch(SQLException e)
	{
		System.out.println("here i am :"+e.getMessage());

	}
   }
}


=====

would you like to help someone see the beauty of the world through your eyes long after you have gone http://www.ebai.org

Arun VC, E Team India Web Solutions, 
Serene,Anupama Nagar,Pongummoodu,Trivandrum
Phone Off: +91 471 558089. Res : +91 471 343954. 
http://www.e-zenit.it 
http://www.geocities.com/vcarun


__________________________________________________
Do You Yahoo!?
Yahoo! Finance - Get real-time stock quotes
http://finance.yahoo.com

Re: problem in using DatabaseMetaData getColumns()

От:
Dave Cramer <Dave@micro-automation.net>
Дата:
The latest code should work, can you build from cvs?

dave
On Mon, 2002-09-02 at 10:49, arun vc wrote:
> hello 
> 
> i am getting error while using uisng
> dmd.getColumns(null,null,MY_TABLE_NAME,null); 
> i am gtting error while using the new pgjdbc2.jar
> driver with the old driver postgresql.jar this method
> is working .can you help me in solving this problem.
> i am sending a sample code
> 
> 
> import java.sql.DatabaseMetaData;
> import java.sql.SQLException;
> import java.sql.ResultSet;	
> 
> class CheckDB
> {
> public static void main(String args[])throws
> Exception{
> 	
> String MY_TABLE_NAME="computers";
> Connection con;
> 
> 	try
> 	{
> 
> 		Class.forName("org.postgresql.Driver");
> 		con =
> DriverManager.getConnection(jdbc:postgresql://localhost/mytab,loginname,password);
> 		
> 		DatabaseMetaData dmd = con.getMetaData();
> 		String[] tableType = {"TABLE"};  
> 
> 		ResultSet rs = dmd.getTables(null, null, null,
> tableType);
> 
> 		while ( rs.next() )
> 		{
> 			if(MY_TABLE_NAME.equals(rs.getString( "TABLE_NAME"
> )))
> 				System.out.println(MY_TABLE_NAME +" found in
> database " ) ;
> 		}
> 		rs.close();
> 				
> 		rs = dmd.getColumns(null,null,MY_TABLE_NAME,null); 
> 		// when i try to use
> getColumns(null,null,MY_TABLE_NAME,null); method
> 		// i am getting exception :ERROR:  parser: parse
> error at or near "("
> 		// i am gtting this error while using the new
> pgjdbc2.jar Driver
> 		// with the old driver postgresql.jar this method is
> working 
> 
> 		while(rs.next()) 
> 		{	
> 		 colNames[totalFields]=rs.getString( "COLUMN_NAME"
> );//here COLUMN_NAME is a key word
> 		 System.out.println("COLUMN_NAME : " + 
> colNames[totalFields]);
> 		}
> 		rs.close();
> 		
> 	}
> 	catch(SQLException e)
> 	{
> 		System.out.println("here i am :"+e.getMessage());
> 
> 	}
>    }
> }
> 
> 
> =====
> 
> would you like to help someone see the beauty of the world through your eyes long after you have gone http://www.ebai.org
> 
> Arun VC, E Team India Web Solutions, 
> Serene,Anupama Nagar,Pongummoodu,Trivandrum
> Phone Off: +91 471 558089. Res : +91 471 343954. 
> http://www.e-zenit.it 
> http://www.geocities.com/vcarun
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Finance - Get real-time stock quotes
> http://finance.yahoo.com
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
> 
> http://archives.postgresql.org
> 
> 



FAQ