• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

can not connect to Database

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
code
***************
package icc.india.bcci;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class ConnectToPostgresql {

public static void main(String[] args)
{

Connection conn=null;
System.out.println("-------- PostgreSQL JDBC Connection Testing ------------");



System.out.println("Hello");
try {
Class.forName("org.postgresql.Driver");

conn=DriverManager.getConnection("jdbc:postgresql://localhost:portno/dbname","username","password");

} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println(e);
}
catch (SQLException ex) {
// TODO: handle exception
System.out.println(ex);
}
}
}


org.postgresql.util.PSQLException: Protocol error. Session setup failed.

giving me such error. I had already change the database and setup also but it wont be access
Please need your help
 
Saloon Keeper
Posts: 22107
151
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We need a more complete stacktrace, I think. Although I would recommend that you "google" that error message and see if someone has an explanation as to what it actually means.

As far as I can tell, the code should work, although it isn't the ideal way to connect to a database in a web application.
 
Gautam Panpatil
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi.
Thanks for reply ..i will do it

Regards,
Gautam
 
Opportunity is missed by most people because it is dressed in overalls and looks like work - Edison. Tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic