Hello,
 I just now installed Postgresql-6.5.1 on my RH6.0
 system. It is working
 fine.
 Then I downloaded jdbc6.5.1-2.jar file from the
 repturs site. I renamed
 it postgresql.jar and kept it in
 /usr/local/pgsql/lib directory and
 exported the classpath as:
  export

CLASSPATH=\/usr/local/lib/finder.jar:/usr/local/postgresql.jar:.java.uk.org.retep.finder.Main
 
 Once this is done I tried to make connection to my
 driver by this
 program..
 
   import java.net.URL;
 import java.sql.*;
> 
> class SimpleSelect {
> 
> public static void main (String args[]) {
>        String url   =
> ".java.uk.org.retep.finder.Main";
>      String query = "SELECT * FROM emp";
>   try {
>       
>             Class.forName ("postgresql.Driver");
>          DriverManager.setLogStream(System.out);    
>     
>      Connection con = DriverManager.getConnection
> (url,
> "postgres","postgres");          
>  checkForWarning (con.getWarnings ());        
>   
>               DatabaseMetaData dma = con.getMetaData
> ();
>           System.out.println("\nConnected to " +
> dma.getURL());
>   System.out.println("Driver       " +              
>     
> dma.getDriverName());
>        System.out.println("Version      " +         
>          
> dma.getDriverVersion());
>         System.out.println("");        
> 
>      Statement stmt = con.createStatement ();       
>         ResultSet rs = stmt.executeQuery (query);   
>       dispResultSet (rs);            
>   rs.close();    
>   stmt.close();  
>    con.close();  
>   }
>  catch (SQLException ex)
>  {             
>    System.out.println ("\n*** SQLException caught
> ***\n");
> while (ex != null) {
>     System.out.println ("SQLState: " +ex.getSQLState
> ());
>     System.out.println ("Message:  " + ex.getMessage
> ());
>  System.out.println ("Vendor:   " +ex.getErrorCode
> ());
>      ex = ex.getNextException ();  
>           System.out.println ("");
>      }
>     }
>  catch (java.lang.Exception ex)
>  {   
>     ex.printStackTrace ();
> }
> }
> 
> private static boolean checkForWarning (SQLWarning
> warn) throws
> SQLException
>  {  
> boolean rc = false; 
>  if (warn != null)
> {
>     System.out.println ("\n *** Warning ***\n");
>         rc = true;
>         while (warn != null)
> {
>           System.out.println ("SQLState: "
> +warn.getSQLState ());
>            System.out.println ("Message:  "
> +warn.getMessage ());
>             System.out.println ("Vendor:   "
> +warn.getErrorCode ());
>              System.out.println ("");         
>                warn = warn.getNextWarning ();
>    }
>   }
>   return rc;
> }
> private static void dispResultSet (ResultSet rs)  
> throws SQLException{
>     int i;  
>  ResultSetMetaData rsmd = rs.getMetaData ();
>  int numCols = rsmd.getColumnCount ();  
>      for (i=1; i<=numCols; i++)
> {
>    if (i > 1) System.out.print(",");
>            
> System.out.print(rsmd.getColumnLabel(i));
> }       System.out.println("");         
> boolean more = rs.next ();      while (more) {      
> 
>  for (i=1; i<=numCols; i++)
> {
>           if (i > 1) System.out.print(",");
>        System.out.print(rs.getString(i));
>   }
>        System.out.println("");        
>   more = rs.next ();      }}
> 
> }
> 
> Is there some mistake in the program??
> Also, is the driver placed correctly or I need to
> manually need to
> recompile the driver??
> I am using Java-1.2.
> Please suggest the modification in the code as well
> as driver
> installation, as I am new to this.
> 
> Thanking YOu all,
> Alpesh
> 

===
KOTHARI ALPESH D.
STUDENT M. TECH.
CEDT
INDIAN INSTITUTE OF SCIENCE
BANGALORE-560 012
INDIA
__________________________________________________
Do You Yahoo!?
Bid and sell for free at http://auctions.yahoo.com


----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to