Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Help with connecting to database

0 views
Skip to first unread message

mdapol

unread,
May 15, 2001, 7:35:45 PM5/15/01
to
Hello,

I hope someone here can help because I've run out of options. I'm
trying to write a java application to access a Postgresql
database here on our system, but I'm getting an error that I
don't understand when the application runs. I would appreciate
any help that you can give as I am unsure how to solve this.

Here is the beginning of the code that is causing the error:

public class QALogUpdater // Create the class
{

public QALogUpdater(ReportParams theseRepParams,
Vector theseVdatas,
Vector theseFields,
Vector theseTestTypes,
Vector theseTestResults,
ArrayList theseTestParams,
String thisFlag,
String thisExplanation )
{ // Create the constructor

fileParams = theseRepParams;
vdata = theseVdatas;
field = theseFields;
testType = theseTestTypes;
testResult = theseTestResults;
testParams = theseTestParams;
qaFlag = thisFlag;
qaExplanation = thisExplanation;

} // End "public QALogUpdater(...."

public void updateLog() throws ClassNotFoundException,
SQLException
{ // The routine to update the QA Log

//Statement stmt; // Holds SQL statement
String command = new String();
String db =
new String("jdbc:postgresql://yngvi/qa_log_test");
String usr = new String("mda");
String pwd = new String("blah");

Class.forName("org.postgresql.Driver");
// Load database interface


java.sql.DriverManager.setLogStream(java.lang.System.out);

Connection conn =
DriverManager.getConnection( db, usr, pwd );

Statement stmt = conn.createStatement();

When executing the "Connection conn = ..." statement, I get the
following error:

DriverManager.getConnection("jdbc:postgresql://yngvi/qa_log_test")
trying
driver[className=org.postgresql.Driver,org.postgresql.Driver@6a9d42]
java.sql.SQLException: ERROR: MultiByte strings (MB) must be
enabled to use this function

at org.postgresql.Connection.ExecSQL(Connection.java:533)
at org.postgresql.Connection.ExecSQL(Connection.java:400)
at
org.postgresql.Connection.openConnection(Connection.java:270)
at org.postgresql.Driver.connect(Driver.java:122)
at
java.sql.DriverManager.getConnection(DriverManager.java:517)
at
java.sql.DriverManager.getConnection(DriverManager.java:177)
at qa.shared.QALogUpdater.updateLog(QALogUpdater.java:50)
at qa.shared.Result.reportResult(Result.java:127)
at
qa.analyzer.ConfigFileReader.<init>(ConfigFileReader.java:83)
at QAAnalyzer.main(QAAnalyzer.java:156)
java.lang.NullPointerException

I don't understand what MultiByte strings have to do with this
error since we're not using anything other than ASCII in the
database, and besides my system administrator assures me that
multibyte strings are enabled in Postgres here.

If I change the connection statement to:
Connection conn =
DriverManager.getConnection( db );

then I get a slightly different error. There is no stack trace,
but I still get a java.lang.NullPointerException.

The database exists, the username and password is valid. Any
help is appreciated.

alexday

unread,
May 16, 2001, 3:35:00 AM5/16/01
to
That is a Postgres specific problem. I presume that there is
documentation provided with their JDBC implementation. I suggest
you read through the documentation for an explanation of that
error message.

Side note - I notice you instantiate Strings as follows:

String myStr = new String("Blah blah blah");

This is "overkill" as this creates TWO strings. The first is...

"Blah blah blah"

.. and the second is...

new String("Blah blah blah")

This entails creation of TWO objects. You can simplify this to...

String myStr = "Blah blah blah";


mdapol

unread,
May 16, 2001, 12:14:48 PM5/16/01
to
alexday wrote:
>That is a Postgres specific problem. I presume that there is
>documentation provided with their JDBC implementation. I suggest
>you read through the documentation for an explanation of that
>error message.

I've already read through their documentation. It doesn't say
anything about that or any error message. Their JDBC
documentation is pretty sparse. Are you saying that this is not
a Java problem?

>Side note - I notice you instantiate Strings as follows:
>
>String myStr = new String("Blah blah blah");
>
>This is "overkill" as this creates TWO strings. The first is...
>
>"Blah blah blah"
>

>... and the second is...


>
>new String("Blah blah blah")
>
>This entails creation of TWO objects. You can simplify this
to...
>
>String myStr = "Blah blah blah";

Thanks for the advice. I would still appreciate any help on the
original question though. Is there another forum I could post
on?

Mark

dhollon

unread,
May 16, 2001, 12:30:22 PM5/16/01
to
Mark,

In response to Alexday's "Overkill". Because of how the shared
pool of Strings works and the fact that Strings are immutable it
is impossible to have 2 String objects that are equal to "Blah
blah blah". The way you created your String was fine use which
ever way is best for you.

Dale

0 new messages