Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

sql exception : user property is missing ???

 
mudassir shahab
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi

i am using postgres on redhat 9 ...i have written a jdbc code for connection with postgres...when i run it ....it gives the following error


SQL EXCEPTION The user property is missing. It is mandatory.


the code is as follows :

import java.sql.*;

class mydb

{

public static void main(String [] args)

{
Connection dbconn ;
Statement stmt ;
ResultSet author ;
String sourceURL = "jdbc ostgresql://localhost/synergy";
try
{

Class.forName("org.postgresql.Driver");

dbconn = DriverManager.getConnection(sourceURL);
stmt = dbconn.createStatement();
author = stmt.executeQuery("SELECT * FROM cust_info");


while(author.next())
{

System.out.println(author.getString("cust_id"));
}


dbconn.setAutoCommit(true);

stmt.close() ;

}


catch(ClassNotFoundException cnfe){

System.out.println("CLASS NOT FOUND EXCEPTION "+cnfe);

}

catch(SQLException sqle){

System.out.println("SQL EXCEPTION "+sqle);

}
}
}

plz solve it out.....
 
Nicolas Taillepied
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I hope that you've solved your problem.
If you don't, try :
dbconn = DriverManager.getConnection(sourceURL,"your user name for postgres","your password");
instead of dbconn = DriverManager.getConnection(sourceURL);
Good luck
Nicolas
 
Tim Holloway
Saloon Keeper
Posts: 18303
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
PostgreSQL, like many modern DBMSs is designed with the idea that many users/applications will be sharing the same database(s) and that some should be allowed to do things that other aren't. A good example I saw the other day was in a financial system, where users could add transactions, but not update or remove them (in accounting, you should always add a cancelling transaction, not simply delete a bad one, so that a full audit trail is preserved).

So what a userid/password gives you is a way of attaching to a specific set of security rules. It often does other things as well, but security is one of the more important reasons.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic