No Postgres username specified in packet

Поиск
Список
Период
Сортировка
Искать

No Postgres username specified in packet

От:
"Gordon A. Campbell" <gordie@columbia.edu>
Дата:


First crack at using postgres. I'll take whatever suggestions you can
pass on. Running under Linux/Redhat. Has anybody seen this error? Checked
to see if -i was there, checked classpath to point to the .jar files.
Is this a "normal" error? Doesn't seem like it's getting past the driver
call.



$java sample  
Exception caught. 
Something unusual has occured to cause the driver to fail. Please report
this exception: java.sql.SQLException: No Postgres username specified in
startup packet.
Something unusual has occured to cause the driver to fail. Please report
this exception: java.sql.SQLException: No Postgres username specified in
startup packet.
at org.postgresql.Driver.connect(Driver.java:125)
at java.sql.DriverManager.getConnection(DriverManager.java:453)
at java.sql.DriverManager.getConnection(DriverManager.java:133)
at sample.(sample.java:18)
at sample.main(sample.java:47)


import java.io.*;
import java.sql.*;


public class sample
{

Connection conn;
Statement stmt;
String state_code;

public sample() throws ClassNotFoundException, FileNotFoundException,
IOException, SQLException

{
Class.forName("org.postgresql.Driver");System.err.println("made it this far");System.out.println("made it this far");
conn =
DriverManager.getConnection("jdbc:postgresql://127.0.0.1/testdb","testuser","");stmt = conn.createStatement();
System.out.print("Enter a state code: ");System.out.flush();BufferedReader r = new BufferedReader(new
InputStreamReader(System.in));state_code = r.readLine();
ResultSet res = stmt.executeQuery(		"Select name " +		"From statename " +		"Where code = '" + state_code + "'");
if (res !=null)	while(res.next())	{	String state_name = res.getString(1);	System.out.println(state_name);	}
	res.close();	stmt.close();	conn.close();
}

public static void main(String args[])
{
try{	sample testdb = new sample();   }catch(Exception exc)   {   	System.err.println("Exception caught. \n" + exc);	exc.printStackTrace();   }   
}


}




FAQ