This week's book giveaway is in the
Agile and other Processes
forum.
We're giving away four copies of
The Mikado Method
and have Ola Ellnestam and Daniel Brolund on-line!
See
this thread
for details.
A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
Win a copy of
The Mikado Method
this week in the
Agile and other Processes
forum!
JavaRanch
»
Java Forums
»
Databases
»
JDBC
Author
problem connecting to postgres 8.2.3
Anand Shrivastava
Ranch Hand
Joined: Jul 22, 2007
Posts: 125
posted
Jul 22, 2007 00:28:00
0
With the following code, i am getting error of class not found exception:
package screen; import javax.swing.*; import java.sql.*; /** * * @author Lenovo */ public class connect { public String uname,pwd; public char dname; connect(char dbase,String username,String password) { dname=dbase; uname=username; pwd=password; } /** Creates a new instance of connect */ public Connection connected(){ Connection conn; String dstr=new String(); String db=new String(); switch(dname) { case 'o':dstr="oracle.jdbc.driver.OracleDriver"; db="jdbc:oracle:oci:@xe"; break; case 'p':dstr="org.postgresql.Driver"; db="jdbc:postgresql://localhost:5432/postgres"; break; } try { Class.forName(dstr); } catch (Exception E) { System.err.println("Unable to load driver"); E.printStackTrace(); } try { conn = DriverManager.getConnection(db,uname,pwd); System.out.println("Connected to database"); return conn; } catch (SQLException E) { System.out.println("SQLException: " + E.getMessage()); System.out.println("SQLState: "+E.getSQLState()); System.out.println("VenderError: "+ E.getErrorCode()); } return null; } ResultSet jset(String query) { ResultSet rset; try { System.out.println(dname); Statement smnt = connected().createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); rset = smnt.executeQuery(query); return (rset); } catch (Exception E) {System.out.println(E.getMessage()); return (null);} } // public static void main(String args[]) {connect com;} }
Anand Shrivastava
SCJA
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35241
7
posted
Jul 22, 2007 02:25:00
0
Welcome to JavaRanch.
Which class is it that is not found? The error message should tell you that. Is the missing class in your classpath?
Android apps
–
ImageJ plugins
–
Java web charts
Anand Shrivastava
Ranch Hand
Joined: Jul 22, 2007
Posts: 125
posted
Jul 24, 2007 01:03:00
0
i have solved the issue. it was classpath trouble. thanks.
I agree. Here's the link:
http://ej-technologies/jprofiler
- if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
subject: problem connecting to postgres 8.2.3
Similar Threads
Cannot open connection issue
Problem in returning the username
Reading usersnames/passwords from file for database access
need java logic
AbstractTableModel NullPointerException
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter