pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feedorg.postgresql.util.PSQLException: Protocol error. Session setup failed
15+ messages / 7 participants
[nested] [flat]
* org.postgresql.util.PSQLException: Protocol error. Session setup failed
@ 2010-03-09 16:51 Major Services <services.major@gmail.com>
0 siblings, 2 replies; 15+ messages in thread
From: Major Services @ 2010-03-09 16:51 UTC (permalink / raw)
To: pgsql-jdbc
I am trying to connect to PostgreSQL database on my local system.
The code is:
Class.forName("org.postgresql.Driver");
String url =
"jdbc:postgresql://localhost:5432/postgres?user=postgres&password=major";
Connection conn = DriverManager.getConnection(url);
Running the code I get:
org.postgresql.util.PSQLException: Protocol error. Session setup failed.
Using postgresql-8.4-701.jdbc3 on PostgreSql 8.4
^ permalink raw reply [nested|flat] 15+ messages in thread
* Re: org.postgresql.util.PSQLException: Protocol error. Session setup failed
@ 2010-03-09 16:56 dmp <danap@ttc-cmc.net>
parent: Major Services <services.major@gmail.com>
1 sibling, 2 replies; 15+ messages in thread
From: dmp @ 2010-03-09 16:56 UTC (permalink / raw)
To: Major Services <services.major@gmail.com>; pgsql-jdbc
Did not look up error, but looks like the Class.forName().
Attached standard main() to create a connection to PostgreSQL.
danap.
Attachments:
standardmain_connect.java (text/plain, 1.3K) download
//============================================================
// Main public access point method for instantiating the
// PostgreSQL_JDBC application. Arguments: database, username,
// & password.
// ==============================================================
public static void main(String[] args) throws SQLException, InstantiationException,
IllegalAccessException, ClassNotFoundException, InterruptedException
{
String host, database, username, password;
Connection dbConnection;
// Collect connection properties. and setup connection.
//host = "cindy";
host = "localhost";
if (args.length != 0)
{
database = args[0];
username = (args.length > 1) ? args[1] : null;
password = (args.length > 2) ? args[2] : null;
}
else
{
database = "key_tables";
username = "";
password = "";
}
dbConnection = null;
Class.forName("org.postgresql.Driver").newInstance();
dbConnection = DriverManager.getConnection("jdbc:postgresql://" + host + "/" + database, username,
password);
System.out.println("Connection Created");
new PostgreSQL_JDBC(dbConnection);
// Close.
dbConnection.close();
System.out.println("Connection Closed");
}
^ permalink raw reply [nested|flat] 15+ messages in thread
* Re: org.postgresql.util.PSQLException: Protocol error. Session setup failed
@ 2010-03-09 17:22 Maciek Sakrejda <msakrejda@truviso.com>
parent: dmp <danap@ttc-cmc.net>
1 sibling, 0 replies; 15+ messages in thread
From: Maciek Sakrejda @ 2010-03-09 17:22 UTC (permalink / raw)
To: dmp <danap@ttc-cmc.net>; +Cc: Major Services <services.major@gmail.com>; pgsql-jdbc
I don't imagine Class.forName() would throw a PSQLException.
If I'm reading the ConnectionFactoryImpl code correctly, the server
seems to be responding to the Startup message with something that is
neither an error nor an authentication request, which seems weird. Can
you use Wireshark or tcpdump to look at traffic on the wire?
---
Maciek Sakrejda | Software Engineer | Truviso
1065 E. Hillsdale Blvd., Suite 230
Foster City, CA 94404
(650) 242-3500 Main
(650) 242-3516 T
(510) 717-5398 M
(650) 242-3501 F
msakrejda@truviso.com
www.truviso.com
On Tue, Mar 9, 2010 at 8:56 AM, dmp <danap@ttc-cmc.net> wrote:
> Did not look up error, but looks like the Class.forName().
> Attached standard main() to create a connection to PostgreSQL.
>
> danap.
>
>
> //============================================================
> // Main public access point method for instantiating the
> // PostgreSQL_JDBC application. Arguments: database, username,
> // & password.
> // ==============================================================
>
> public static void main(String[] args) throws SQLException,
> InstantiationException,
> IllegalAccessException, ClassNotFoundException, InterruptedException
> {
> String host, database, username, password;
> Connection dbConnection;
>
> // Collect connection properties. and setup connection.
>
> //host = "cindy";
> host = "localhost";
>
> if (args.length != 0)
> {
> database = args[0];
> username = (args.length > 1) ? args[1] : null;
> password = (args.length > 2) ? args[2] : null;
> }
> else
> {
> database = "key_tables";
> username = "";
> password = "";
> }
>
> dbConnection = null;
> Class.forName("org.postgresql.Driver").newInstance();
> dbConnection = DriverManager.getConnection("jdbc:postgresql://" + host
> + "/" + database, username,
> password);
> System.out.println("Connection Created");
>
> new PostgreSQL_JDBC(dbConnection);
>
> // Close.
> dbConnection.close();
> System.out.println("Connection Closed");
> }
>
> --
> Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-jdbc
>
>
^ permalink raw reply [nested|flat] 15+ messages in thread
* Re: org.postgresql.util.PSQLException: Protocol error. Session setup failed
@ 2010-03-09 17:41 Major Services <services.major@gmail.com>
parent: dmp <danap@ttc-cmc.net>
1 sibling, 1 reply; 15+ messages in thread
From: Major Services @ 2010-03-09 17:41 UTC (permalink / raw)
To: dmp <danap@ttc-cmc.net>; +Cc: pgsql-jdbc
Output is :
//============================================================ // Main
public access point method for instantiating the // PostgreSQL_JDBC
application. Arguments: database, username, // & password. //
============================================================== public static
void main(String[] args) throws SQLException, InstantiationException,
IllegalAccessException, ClassNotFoundException, InterruptedException {
String host, database, username, password; Connection dbConnection; //
Collect connection properties. and setup connection. //host = "cindy"; host
= "localhost"; if (args.length != 0) { database = args[0]; username =
(args.length > 1) ? args[1] : null; password = (args.length > 2) ? args[2] :
null; } else { database = "postgres"; username = "postgres"; password =
"major"; } dbConnection = null;
Class.forName("org.postgresql.Driver").newInstance(); dbConnection =
DriverManager.getConnection("jdbc:postgresql://" + host + "/" + database,
username, password); System.out.println("Connection Created"); new
PostgreSQL_JDBC(dbConnection); // Close. dbConnection.close();
System.out.println("Connection Closed"); }
On Tue, Mar 9, 2010 at 10:26 PM, dmp <danap@ttc-cmc.net> wrote:
> Did not look up error, but looks like the Class.forName().
> Attached standard main() to create a connection to PostgreSQL.
>
> danap.
>
>
> //============================================================
> // Main public access point method for instantiating the
> // PostgreSQL_JDBC application. Arguments: database, username,
> // & password.
> // ==============================================================
>
> public static void main(String[] args) throws SQLException,
> InstantiationException,
> IllegalAccessException, ClassNotFoundException,
> InterruptedException
> {
> String host, database, username, password;
> Connection dbConnection;
>
> // Collect connection properties. and setup connection.
>
> //host = "cindy";
> host = "localhost";
>
> if (args.length != 0)
> {
> database = args[0];
> username = (args.length > 1) ? args[1] : null;
> password = (args.length > 2) ? args[2] : null;
> }
> else
> {
> database = "key_tables";
> username = "";
> password = "";
> }
>
> dbConnection = null;
> Class.forName("org.postgresql.Driver").newInstance();
> dbConnection = DriverManager.getConnection("jdbc:postgresql://" + host
> + "/" + database, username,
> password);
> System.out.println("Connection Created");
>
> new PostgreSQL_JDBC(dbConnection);
>
> // Close.
> dbConnection.close();
> System.out.println("Connection Closed");
> }
>
^ permalink raw reply [nested|flat] 15+ messages in thread
* Re: org.postgresql.util.PSQLException: Protocol error. Session setup failed
@ 2010-03-09 22:32 Mark Kirkwood <mark.kirkwood@catalyst.net.nz>
parent: Major Services <services.major@gmail.com>
1 sibling, 1 reply; 15+ messages in thread
From: Mark Kirkwood @ 2010-03-09 22:32 UTC (permalink / raw)
To: Major Services <services.major@gmail.com>; +Cc: pgsql-jdbc
Major Services wrote:
> I am trying to connect to PostgreSQL database on my local system.
>
> The code is:
>
> Class.forName("org.postgresql.Driver");
> String url =
> "jdbc:postgresql://localhost:5432/postgres?user=postgres&password=major";
> Connection conn = DriverManager.getConnection(url);
>
> Running the code I get:
>
> org.postgresql.util.PSQLException: Protocol error. Session setup failed.
>
> Using postgresql-8.4-701.jdbc3 on PostgreSql 8.4
>
>
>
>
>
Try adding some debug info (will help us see what is going on) - e.g:
Class.forName("org.postgresql.Driver");
String url =
"jdbc:postgresql://localhost:5432/postgres?user=postgres&password=major";
Properties props = new Properties();
props.setProperty("loglevel","2");
Connection conn = DriverManager.getConnection(url, props);
regards
Mark
^ permalink raw reply [nested|flat] 15+ messages in thread
* Re: org.postgresql.util.PSQLException: Protocol error. Session setup failed
@ 2010-03-10 14:31 Major Services <services.major@gmail.com>
parent: Mark Kirkwood <mark.kirkwood@catalyst.net.nz>
0 siblings, 3 replies; 15+ messages in thread
From: Major Services @ 2010-03-10 14:31 UTC (permalink / raw)
To: Mark Kirkwood <mark.kirkwood@catalyst.net.nz>; +Cc: pgsql-jdbc
Hi,
Following is the error report:
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 13 in the jsp file: /jsp/pgtest.jsp
Properties cannot be resolved to a type
10: {
11: Class.forName("org.postgresql.Driver");
12: String url =
"jdbc:postgresql://localhost:5432/postgres?user=postgres&password=major";
13: Properties props = new Properties();
14: props.setProperty("loglevel","2");
15: Connection conn = DriverManager.getConnection(url, props);
16: }
Thanks
On Wed, Mar 10, 2010 at 4:02 AM, Mark Kirkwood <
mark.kirkwood@catalyst.net.nz> wrote:
> Major Services wrote:
>
>> I am trying to connect to PostgreSQL database on my local system.
>>
>> The code is:
>>
>> Class.forName("org.postgresql.Driver");
>> String url =
>> "jdbc:postgresql://localhost:5432/postgres?user=postgres&password=major";
>> Connection conn = DriverManager.getConnection(url);
>>
>> Running the code I get:
>>
>> org.postgresql.util.PSQLException: Protocol error. Session setup failed.
>>
>> Using postgresql-8.4-701.jdbc3 on PostgreSql 8.4
>>
>>
>>
>>
>>
>>
> Try adding some debug info (will help us see what is going on) - e.g:
>
>
>
> Class.forName("org.postgresql.Driver");
> String url =
> "jdbc:postgresql://localhost:5432/postgres?user=postgres&password=major";
>
> Properties props = new Properties();
> props.setProperty("loglevel","2");
>
> Connection conn = DriverManager.getConnection(url, props);
>
>
>
> regards
>
> Mark
>
^ permalink raw reply [nested|flat] 15+ messages in thread
* Re: org.postgresql.util.PSQLException: Protocol error. Session setup failed
@ 2010-03-10 14:54 Guillaume Cottenceau <gc@mnc.ch>
parent: Major Services <services.major@gmail.com>
2 siblings, 1 reply; 15+ messages in thread
From: Guillaume Cottenceau @ 2010-03-10 14:54 UTC (permalink / raw)
To: Major Services <services.major@gmail.com>; +Cc: pgsql-jdbc
Major Services <services.major 'at' gmail.com> writes:
> Hi,
> Following is the error report:
lol!
(sorry, couldn't resist)
> org.apache.jasper.JasperException: Unable to compile class for JSP:
>
> An error occurred at line: 13 in the jsp file: /jsp/pgtest.jsp
> Properties cannot be resolved to a type
>
> 10: {
> 11: Class.forName("org.postgresql.Driver");
> 12: String url = "jdbc:postgresql://localhost:5432/postgres?user=postgres&password=major";
> 13: Properties props = new Properties();
> 14: props.setProperty("loglevel","2");
>
> 15: Connection conn = DriverManager.getConnection(url, props);
> 16: }
>
--
Guillaume Cottenceau
^ permalink raw reply [nested|flat] 15+ messages in thread
* Re: org.postgresql.util.PSQLException: Protocol error. Session setup failed
@ 2010-03-10 17:30 dmp <danap@ttc-cmc.net>
parent: Guillaume Cottenceau <gc@mnc.ch>
0 siblings, 0 replies; 15+ messages in thread
From: dmp @ 2010-03-10 17:30 UTC (permalink / raw)
To: Guillaume Cottenceau <gc@mnc.ch>; pgsql-jdbc
This output error is total unrelated to your original error and does not
involve
the jdbc. Perhaps you should back out and try from simple to more
complicated.
1. Connect on the local system with psql
2. Create a simple application, not using a servlet, and try connecting.
You can use the sample main as I posted to do this or your own code.
3. Make sure a simple servlet, not using the database is working.
> Hi,
> Following is the error report:
>
> org.apache.jasper.JasperException: Unable to compile class for JSP:
>
> An error occurred at line: 13 in the jsp file: /jsp/pgtest.jsp
> Properties cannot be resolved to a type
> 10: {
> 11: Class.forName("org.postgresql.Driver");
> 12: String url =
> "jdbc:postgresql://localhost:5432/postgres?user=postgres&password=major";
> 13: Properties props = new Properties();
> 14: props.setProperty("loglevel","2");
> 15: Connection conn = DriverManager.getConnection(url, props);
> 16: }
I'm in agreement with Maciek comments here. I can not duplicate
your PSQLException with problem with Class.forName or any other
invalid input for connection.
danap
> I don't imagine Class.forName() would throw a PSQLException.
>
> If I'm reading the ConnectionFactoryImpl code correctly, the server
> seems to be responding to the Startup message with something that is
> neither an error nor an authentication request, which seems weird. Can
> you use Wireshark or tcpdump to look at traffic on the wire?
> ---
> Maciek Sakrejda | Software Engineer | Truviso
> Class.forName("org.postgresql.Driver");
> String url =
> "jdbc:postgresql://localhost:5432/postgres?user=postgres&password=major";
> Connection conn = DriverManager.getConnection(url);
>
> Running the code I get:
>
> org.postgresql.util.PSQLException: Protocol error. Session setup failed.
>
> Using postgresql-8.4-701.jdbc3 on PostgreSql 8.4
^ permalink raw reply [nested|flat] 15+ messages in thread
* Re: org.postgresql.util.PSQLException: Protocol error. Session setup failed
@ 2010-03-10 18:34 Major Services <services.major@gmail.com>
parent: Major Services <services.major@gmail.com>
2 siblings, 2 replies; 15+ messages in thread
From: Major Services @ 2010-03-10 18:34 UTC (permalink / raw)
To: Mark Kirkwood <mark.kirkwood@catalyst.net.nz>; +Cc: pgsql-jdbc
Please ignore the previous output.
Here is the one to consider:
org.apache.jasper.JasperException: An exception occurred processing
JSP page /jsp/pgtest.jsp at line 14
11: String url =
"jdbc:postgresql://localhost:5432/postgres?user=postgres&password=major";
12: Properties props = new Properties();
13: props.setProperty("loglevel","2");
14: Connection conn = DriverManager.getConnection(url , props);
15: }
16: %>
17: </body>
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:505)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:398)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
*root cause*
javax.servlet.ServletException: org.postgresql.util.PSQLException:
Protocol error. Session setup failed.
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:862)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
org.apache.jsp.jsp.pgtest_jsp._jspService(pgtest_jsp.java:80)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
*root cause*
org.postgresql.util.PSQLException: Protocol error. Session setup failed.
org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:402)
org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:108)
org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:66)
org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:125)
org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:30)
org.postgresql.jdbc3.Jdbc3Connection.<init>(Jdbc3Connection.java:24)
org.postgresql.Driver.makeConnection(Driver.java:393)
org.postgresql.Driver.connect(Driver.java:267)
java.sql.DriverManager.getConnection(DriverManager.java:525)
java.sql.DriverManager.getConnection(DriverManager.java:140)
org.apache.jsp.jsp.pgtest_jsp._jspService(pgtest_jsp.java:68)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
On Wed, Mar 10, 2010 at 8:01 PM, Major Services <services.major@gmail.com>wrote:
> Hi,
> Following is the error report:
>
> org.apache.jasper.JasperException: Unable to compile class for JSP:
>
> An error occurred at line: 13 in the jsp file: /jsp/pgtest.jsp
> Properties cannot be resolved to a type
>
> 10: {
> 11: Class.forName("org.postgresql.Driver");
> 12: String url = "jdbc:postgresql://localhost:5432/postgres?user=postgres&password=major";
> 13: Properties props = new Properties();
> 14: props.setProperty("loglevel","2");
>
> 15: Connection conn = DriverManager.getConnection(url, props);
> 16: }
>
> Thanks
>
>
> On Wed, Mar 10, 2010 at 4:02 AM, Mark Kirkwood <
> mark.kirkwood@catalyst.net.nz> wrote:
>
>> Major Services wrote:
>>
>>> I am trying to connect to PostgreSQL database on my local system.
>>>
>>> The code is:
>>>
>>> Class.forName("org.postgresql.Driver");
>>> String url =
>>> "jdbc:postgresql://localhost:5432/postgres?user=postgres&password=major";
>>> Connection conn = DriverManager.getConnection(url);
>>>
>>> Running the code I get:
>>>
>>> org.postgresql.util.PSQLException: Protocol error. Session setup failed.
>>>
>>> Using postgresql-8.4-701.jdbc3 on PostgreSql 8.4
>>>
>>>
>>>
>>>
>>>
>>>
>> Try adding some debug info (will help us see what is going on) - e.g:
>>
>>
>>
>> Class.forName("org.postgresql.Driver");
>> String url =
>> "jdbc:postgresql://localhost:5432/postgres?user=postgres&password=major";
>>
>> Properties props = new Properties();
>> props.setProperty("loglevel","2");
>>
>> Connection conn = DriverManager.getConnection(url, props);
>>
>>
>>
>> regards
>>
>> Mark
>>
>
>
^ permalink raw reply [nested|flat] 15+ messages in thread
* Re: org.postgresql.util.PSQLException: Protocol error. Session setup failed
@ 2010-03-10 18:40 Kevin Grittner <Kevin.Grittner@wicourts.gov>
parent: Major Services <services.major@gmail.com>
1 sibling, 0 replies; 15+ messages in thread
From: Kevin Grittner @ 2010-03-10 18:40 UTC (permalink / raw)
To: Mark Kirkwood <mark.kirkwood@catalyst.net.nz>; Major Services <services.major@gmail.com>; +Cc: pgsql-jdbc
Major Services <services.major@gmail.com> wrote:
> "jdbc:postgresql://localhost:5432/postgres?user=postgres&password=
> major"
> *root cause*
>
> org.postgresql.util.PSQLException: Protocol error. Session setup
> failed.
> org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(
> ConnectionFactoryImpl.java:402)
> org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(
> ConnectionFactoryImpl.java:108)
What happens if you try to connect with:
psql -h localhost -p 5432 postgres postgres
and type major as the password when prompted?
-Kevin
^ permalink raw reply [nested|flat] 15+ messages in thread
* Re: org.postgresql.util.PSQLException: Protocol error. Session setup failed
@ 2010-03-10 18:41 Maciek Sakrejda <msakrejda@truviso.com>
parent: Major Services <services.major@gmail.com>
1 sibling, 0 replies; 15+ messages in thread
From: Maciek Sakrejda @ 2010-03-10 18:41 UTC (permalink / raw)
To: Major Services <services.major@gmail.com>; +Cc: Mark Kirkwood <mark.kirkwood@catalyst.net.nz>; pgsql-jdbc
Okay, this looks like the stack trace you originally posted. So now
we're back to what we were asking earlier--can you enable logging in
the driver or capture the traffic on the wire with a tool like
Wireshark or tcpdump?
---
Maciek Sakrejda | Software Engineer | Truviso
1065 E. Hillsdale Blvd., Suite 230
Foster City, CA 94404
(650) 242-3500 Main
(650) 242-3501 F
msakrejda@truviso.com
www.truviso.com
On Wed, Mar 10, 2010 at 10:34 AM, Major Services
<services.major@gmail.com> wrote:
> Please ignore the previous output.
>
> Here is the one to consider:
>
> org.apache.jasper.JasperException: An exception occurred processing JSP page
> /jsp/pgtest.jsp at line 14
>
> 11: String url =
> "jdbc:postgresql://localhost:5432/postgres?user=postgres&password=major";
>
> 12: Properties props = new Properties();
> 13: props.setProperty("loglevel","2");
> 14: Connection conn = DriverManager.getConnection(url , props);
> 15: }
> 16: %>
> 17: </body>
>
>
>
> Stacktrace:
> org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:505)
> org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:398)
> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
>
> org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
> javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
>
> root cause
>
> javax.servlet.ServletException: org.postgresql.util.PSQLException: Protocol
> error. Session setup failed.
>
> org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:862)
> org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
> org.apache.jsp.jsp.pgtest_jsp._jspService(pgtest_jsp.java:80)
>
> org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
> javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
> org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
>
> org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
> javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
>
> root cause
>
> org.postgresql.util.PSQLException: Protocol error. Session setup failed.
>
> org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:402)
> org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:108)
> org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:66)
>
> org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:125)
> org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:30)
> org.postgresql.jdbc3.Jdbc3Connection.<init>(Jdbc3Connection.java:24)
>
> org.postgresql.Driver.makeConnection(Driver.java:393)
> org.postgresql.Driver.connect(Driver.java:267)
> java.sql.DriverManager.getConnection(DriverManager.java:525)
> java.sql.DriverManager.getConnection(DriverManager.java:140)
>
> org.apache.jsp.jsp.pgtest_jsp._jspService(pgtest_jsp.java:68)
> org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
> javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
> org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
>
> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
> org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
> javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
>
>
>
> On Wed, Mar 10, 2010 at 8:01 PM, Major Services <services.major@gmail.com>
> wrote:
>>
>> Hi,
>> Following is the error report:
>>
>> org.apache.jasper.JasperException: Unable to compile class for JSP:
>>
>> An error occurred at line: 13 in the jsp file: /jsp/pgtest.jsp
>> Properties cannot be resolved to a type
>>
>>
>> 10: {
>> 11: Class.forName("org.postgresql.Driver");
>> 12: String url =
>> "jdbc:postgresql://localhost:5432/postgres?user=postgres&password=major";
>> 13: Properties props = new Properties();
>>
>> 14: props.setProperty("loglevel","2");
>>
>> 15: Connection conn = DriverManager.getConnection(url, props);
>> 16: }
>>
>> Thanks
>>
>> On Wed, Mar 10, 2010 at 4:02 AM, Mark Kirkwood
>> <mark.kirkwood@catalyst.net.nz> wrote:
>>>
>>> Major Services wrote:
>>>>
>>>> I am trying to connect to PostgreSQL database on my local system.
>>>>
>>>> The code is:
>>>>
>>>> Class.forName("org.postgresql.Driver");
>>>> String url =
>>>> "jdbc:postgresql://localhost:5432/postgres?user=postgres&password=major";
>>>> Connection conn = DriverManager.getConnection(url);
>>>>
>>>> Running the code I get:
>>>>
>>>> org.postgresql.util.PSQLException: Protocol error. Session setup failed.
>>>>
>>>> Using postgresql-8.4-701.jdbc3 on PostgreSql 8.4
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>> Try adding some debug info (will help us see what is going on) - e.g:
>>>
>>>
>>> Class.forName("org.postgresql.Driver");
>>> String url =
>>> "jdbc:postgresql://localhost:5432/postgres?user=postgres&password=major";
>>>
>>> Properties props = new Properties();
>>> props.setProperty("loglevel","2");
>>>
>>> Connection conn = DriverManager.getConnection(url, props);
>>>
>>>
>>>
>>> regards
>>>
>>> Mark
>>
>
>
^ permalink raw reply [nested|flat] 15+ messages in thread
* Re: org.postgresql.util.PSQLException: Protocol error. Session setup failed
@ 2010-03-10 20:31 Mark Kirkwood <mark.kirkwood@catalyst.net.nz>
parent: Major Services <services.major@gmail.com>
2 siblings, 1 reply; 15+ messages in thread
From: Mark Kirkwood @ 2010-03-10 20:31 UTC (permalink / raw)
To: Major Services <services.major@gmail.com>; +Cc: pgsql-jdbc
Oh dear - probably missing imports or something in your code.
Maybe try running a standalone java program from the command line (see
below), as thats what I used to check this:
$ export CLASSPAT=path-to-your-postgresql.jar:.
$ java test1
---- test1.java ---
import java.sql.*;
import java.util.*;
public class test1 {
public static void main( String args[] ) throws Exception {
Class.forName("org.postgresql.Driver");
String url =
"jdbc:postgresql://localhost:5432/postgres?user=postgres&password=major";
Properties props = new Properties();
props.setProperty("loglevel","2");
Connection conn = DriverManager.getConnection(url, props);
System.out.println( "Connected to: " + url );
conn.close ();
}
}
Major Services wrote:
> Hi,
> Following is the error report:
>
> org.apache.jasper.JasperException: Unable to compile class for JSP:
>
> An error occurred at line: 13 in the jsp file: /jsp/pgtest.jsp
> Properties cannot be resolved to a type
>
> 10: {
> 11: Class.forName("org.postgresql.Driver");
> 12: String url = "jdbc:postgresql://localhost:5432/postgres?user=postgres&password=major";
> 13: Properties props = new Properties();
> 14: props.setProperty("loglevel","2");
>
> 15: Connection conn = DriverManager.getConnection(url, props);
> 16: }
>
^ permalink raw reply [nested|flat] 15+ messages in thread
* Re: org.postgresql.util.PSQLException: Protocol error. Session setup failed
@ 2010-03-10 20:32 Mark Kirkwood <mark.kirkwood@catalyst.net.nz>
parent: Mark Kirkwood <mark.kirkwood@catalyst.net.nz>
0 siblings, 1 reply; 15+ messages in thread
From: Mark Kirkwood @ 2010-03-10 20:32 UTC (permalink / raw)
To: Major Services <services.major@gmail.com>; +Cc: pgsql-jdbc
Make that CLASSPATH sorry...!
I wrote:
>
> $ export CLASSPAT=path-to-your-postgresql.jar:.
^ permalink raw reply [nested|flat] 15+ messages in thread
* Re: org.postgresql.util.PSQLException: Protocol error. Session setup failed
@ 2010-03-11 01:45 Lew <noone@lwsc.ehost-services.com>
parent: Major Services <services.major@gmail.com>
0 siblings, 0 replies; 15+ messages in thread
From: Lew @ 2010-03-11 01:45 UTC (permalink / raw)
To: pgsql-jdbc
Major Services wrote:
> Output is :
Output of what?
> //============================================================ // Main
> public access point method for instantiating the // PostgreSQL_JDBC
> application. Arguments: database, username, // & password. //
> ============================================================== public
> static void main(String[] args) throws SQLException,
> InstantiationException, IllegalAccessException, ClassNotFoundException,
> InterruptedException { String host, database, username, password;
> Connection dbConnection; // Collect connection properties. and setup
> connection. //host = "cindy"; host = "localhost"; if (args.length != 0)
> { database = args[0]; username = (args.length > 1) ? args[1] : null;
> password = (args.length > 2) ? args[2] : null; } else { database =
> "postgres"; username = "postgres"; password = "major"; } dbConnection =
> null; Class.forName("org.postgresql.Driver").newInstance(); dbConnection
> = DriverManager.getConnection("jdbc:postgresql://" + host + "/" +
> database, username, password); System.out.println("Connection Created");
> new PostgreSQL_JDBC(dbConnection); // Close. dbConnection.close();
> System.out.println("Connection Closed"); }
Wow, that is some unreadable source code. I see nothing here that sheds light
on your question, though.
What caught my eye in what
dmp wrote:
is
> public static void main(String[] args) throws SQLException,
> InstantiationException,
> IllegalAccessException, ClassNotFoundException,
> InterruptedException
If you don't handle the exceptions, perhaps even with logging, it's harder to
diagnose what went wrong. I am also curious why the declaration of
'InterruptedException' is in the throws list.
> {
> String host, database, username, password;
> Connection dbConnection;
Declared but not instantiated - correct enough except that
...
> dbConnection = null;
assigned here, then
> Class.forName("org.postgresql.Driver").newInstance();
> dbConnection = DriverManager.getConnection("jdbc:postgresql://"
> + host + "/" + database, username,
> password);
the value is replaced here. It's a best practice in Java to declare variables
within the scope of use, and close to the point of use. It doesn't make much
sense to assign a value to the variable that is never used, just thrown away.
Also that argument applies to the invocation of 'newInstance()'. The driver
registers itself with the driver manager on class initialization; the creation
of an instance does nothing but waste time. User code never directly uses
driver instances.
--
Lew
^ permalink raw reply [nested|flat] 15+ messages in thread
* Re: org.postgresql.util.PSQLException: Protocol error. Session setup failed
@ 2010-03-11 01:48 Lew <noone@lwsc.ehost-services.com>
parent: Mark Kirkwood <mark.kirkwood@catalyst.net.nz>
0 siblings, 0 replies; 15+ messages in thread
From: Lew @ 2010-03-11 01:48 UTC (permalink / raw)
To: pgsql-jdbc
Mark Kirkwood wrote:
> Make that CLASSPATH sorry...!
>
> I wrote:
>>
>> $ export CLASSPAT=path-to-your-postgresql.jar:.
Only don't use CLASSPATH, use the "-classpath" (a.k.a., "-cp") option to the
"java" command.
--
Lew
^ permalink raw reply [nested|flat] 15+ messages in thread
end of thread, other threads:[~2010-03-11 01:48 UTC | newest]
Thread overview: 15+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2010-03-09 16:51 org.postgresql.util.PSQLException: Protocol error. Session setup failed Major Services <services.major@gmail.com>
2010-03-09 16:56 ` Re: org.postgresql.util.PSQLException: Protocol error. Session setup failed dmp <danap@ttc-cmc.net>
2010-03-09 17:22 ` Maciek Sakrejda <msakrejda@truviso.com>
2010-03-09 17:41 ` Major Services <services.major@gmail.com>
2010-03-11 01:45 ` Lew <noone@lwsc.ehost-services.com>
2010-03-09 22:32 ` Re: org.postgresql.util.PSQLException: Protocol error. Session setup failed Mark Kirkwood <mark.kirkwood@catalyst.net.nz>
2010-03-10 14:31 ` Major Services <services.major@gmail.com>
2010-03-10 14:54 ` Guillaume Cottenceau <gc@mnc.ch>
2010-03-10 17:30 ` dmp <danap@ttc-cmc.net>
2010-03-10 18:34 ` Major Services <services.major@gmail.com>
2010-03-10 18:40 ` Re: org.postgresql.util.PSQLException: Protocol error. Session setup failed Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-03-10 18:41 ` Maciek Sakrejda <msakrejda@truviso.com>
2010-03-10 20:31 ` Mark Kirkwood <mark.kirkwood@catalyst.net.nz>
2010-03-10 20:32 ` Mark Kirkwood <mark.kirkwood@catalyst.net.nz>
2010-03-11 01:48 ` Lew <noone@lwsc.ehost-services.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox