-----Ursprüngliche Nachricht-----
Von: Martin Rösch [mailto:[EMAIL PROTECTED]]
Gesendet: Donnerstag, 13. Februar 2003 13:20
An: [EMAIL PROTECTED]
Betreff: NullPointerException in the Java Connector


Hi,

attached is my report.

Thank you for your good work.

Kind regards
Martin Rösch

============================================================================
===

From: [EMAIL PROTECTED]
To:   [EMAIL PROTECTED]
Subject: Preparing a statement from a null Java String

Description:
        If  mySqlConnection.prepareStatement(aString) is called in Java
and aString is null, then I get a NullPointerException from deep within
MySQL (at least from my point of view). Here it is:

java.lang.NullPointerException
        at com.mysql.jdbc.PreparedStatement.<init>(Unknown Source)
        at com.mysql.jdbc.jdbc2.PreparedStatement.<init>(Unknown Source)
        at com.mysql.jdbc.jdbc2.Connection.prepareStatement(Unknown Source)
        at com.mysql.jdbc.jdbc2.Connection.prepareStatement(Unknown Source)
        at bos.Auftrag.initializeClass(Auftrag.java:120)
        at bos.Auftrag.getInsertPs(Auftrag.java:150)
        at bos.Auftrag.insertIntoDb(Auftrag.java:263)
        at bos.Auftrag.createTestObject(Auftrag.java:420)
        at bos.MyApplication.createTestData(MyApplication.java:110)
        at bos.MyApplication.<init>(MyApplication.java:57)

Here is the last line from *my* Java code (Auftrag.java:120):

selectAllPs = sqlConn.prepareStatement(selectAllPsString);

I fixed *my* side of the problem by correcting *my* error: I filled the
variable
selectAllPsString with the correct SQL-Command and the problem was gone.

What I would like to ask from you is to maybe provide a diagnostic message
or a java
exception that points straight to the problem like e.g. "Could not prepare
the statement.
Reason: the Java String was null. Fill the String with an SQL-Command and
try again".

Thank you
Martin Rösch


How-To-Repeat:

Prepare a statement from a null String.


Fix:
        None.
Synopsis:       NullPointerException when preparing a statement from a null string
Submitter-Id:   <submitter ID> ??
Originator:     Martin Rösch
Organization:   General Objects LTD
MySQL support:  none
Severity:       non-critical
Priority:       low
Category:       mysql client, I guess the JDBC driver
Class:          change-request
Release:        mysql-3.23.53, MySQL Connector J 2.0.14

Exectutable:   MySQL Connector J 2.0.14
Environment:   ASUS Laptop L8400K
System:        Win2000 Professional
Compiler:      JDK 1.4.0
Architecture:  ???


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to