If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Null userid is not supported

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-30-08, 07:54
SudhakarPothu SudhakarPothu is offline
Registered User
 
Join Date: Jan 2008
Posts: 3
Null userid is not supported

Hi,

I get the following error when i run my Java program to connect DB2 V 9 express Edition database on VMware windowsXP.

com.ibm.db2.jcc.c.SqlException: [ibm][db2][jcc][t4][10205][11234] Null userid is not supported.
at com.ibm.db2.jcc.b.b.E(b.java:1792)
at com.ibm.db2.jcc.b.b.d(b.java:1799)
at com.ibm.db2.jcc.b.b.b(b.java:606)
at com.ibm.db2.jcc.b.b.a(b.java:593)
at com.ibm.db2.jcc.b.b.<init>(b.java:263)
at com.ibm.db2.jcc.DB2Driver.connect(DB2Driver.java:1 63)
at java.sql.DriverManager.getConnection(DriverManager .java:582)
at java.sql.DriverManager.getConnection(DriverManager .java:207)
at utils.Conn.getConn(Conn.java:30)
at IO.Save.insertFile(Save.java:34)
at IO.Save.main(Save.java:62)
java.lang.NullPointerException
at IO.Save.insertFile(Save.java:40)
at IO.Save.main(Save.java:62)

code:

Conn.java

Code:
package utils;

/**
 *
 * @author pothu
 */

import java.sql.*;

public class Conn {
    
    // for simplicity, I've hard-coded account and URL data.
  private static String user = "administrator";
  private static String pwd = "adminadmin";
  private static String url = "jdbc:db2:net:172.17.2.197:50000/TDRepos";

  // this method gets a database connection 	
  public static Connection getConn(){
    Connection conn=null;
		
    //  load the appropriate DB2 driver and 
    //  get a connection to the “test” database  
    try {
       Class.forName("com.ibm.db2.jcc.DB2Driver");
       conn = DriverManager.getConnection(url, user, pwd);
        	
    }
    catch (Exception e) { e.printStackTrace();	}
    return conn;
		
  }   // end getConn();
	
  // this method closes a database connection 
  public static void closeConn(Connection conn){
    try {
      if(conn == null) { return; }
      conn.close();
    }
    catch (Exception e) { e.printStackTrace(); }
    finally { 
      try { conn.close();  }
      catch (Exception e) { } 
    }
  }  // end closeConn();
}  // end class
Save.java

Code:
package IO;

/**
 *
 * @author pothu
 */

import java.io.File;
import java.io.FileInputStream;

import java.sql.Connection;
import java.sql.PreparedStatement;

import utils.Conn;



public class Save {
    
    public static void insertFile(){
  try {
    // for simplicity, I've defined variables with input data 
    String projectId = "TDRepo";
    java.sql.Timestamp  sqlDate = new java.sql.Timestamp(new java.util.Date().getTime());
    String log = "D:/TestDataRepository/TDRepo/DataFiles/Log.xml";  // input Log file
    String report = "D:/TestDataRepository/TDRepo/DataFiles/Report.xml";  // input Report file
    
    //get a connection 
    Connection conn = Conn.getConn();

    //define string that will insert files without validation
    String query = "insert into TESTDATA (PROJECTID, TIMESTAMP, LOGFILE, REPORTFILE) values (?, ?, ? ,?)";

    // prepare the statement
    PreparedStatement insertStmt = conn.prepareStatement(query);
    insertStmt.setString(1, projectId);
    insertStmt.setTimestamp(2, sqlDate);
    File LOG = new File(log);
    insertStmt.setBinaryStream(3, new FileInputStream(LOG), (int)LOG.length());
    File REPORT = new File(report);
    insertStmt.setBinaryStream(4, new FileInputStream(REPORT), (int)REPORT.length());

    //insertStmt.executeUpdate();
    
    //execute the statement 
    if (insertStmt.executeUpdate() != 1) {
        System.out.println("No record inserted.");
    }else{System.out.println("Record inserted.");}
    //. . . 
    conn.close();
  }
  catch (Exception e) {e.printStackTrace(); /*. . .*/ }
}

public static void main(String[] args) {
    
    insertFile();
    
}
}
I will appreciate help

thanks in advance
Reply With Quote
  #2 (permalink)  
Old 01-30-08, 08:51
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
I am not 100% sure but your url looks wrong. It should be:

jdbc:db2:net://172.17.2.197:50000/TDRepos

or

jdbc:db2://172.17.2.197:50000/TDRepos

Andy
Reply With Quote
  #3 (permalink)  
Old 01-30-08, 09:00
SudhakarPothu SudhakarPothu is offline
Registered User
 
Join Date: Jan 2008
Posts: 3
I tried both still the same error.
Reply With Quote
  #4 (permalink)  
Old 01-30-08, 10:48
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
Can you trap the SQLException instead of the generic Exception and print the SQLCode, SQLSTATE and error message?

Andy
Reply With Quote
  #5 (permalink)  
Old 01-30-08, 11:03
SudhakarPothu SudhakarPothu is offline
Registered User
 
Join Date: Jan 2008
Posts: 3
Code:
com.ibm.db2.jcc.c.SqlException: DB2 SQL error: SQLCODE: -204, SQLSTATE: 42704, SQLERRMC: ADMINISTRATOR.TESTDATA
        at com.ibm.db2.jcc.c.fg.e(fg.java:1596)
        at com.ibm.db2.jcc.c.fg.a(fg.java:1206)
        at com.ibm.db2.jcc.b.gb.g(gb.java:140)
        at com.ibm.db2.jcc.b.gb.a(gb.java:39)
        at com.ibm.db2.jcc.b.w.a(w.java:34)
        at com.ibm.db2.jcc.b.vb.g(vb.java:139)
        at com.ibm.db2.jcc.c.fg.n(fg.java:1177)
        at com.ibm.db2.jcc.c.gg.eb(gg.java:1862)
        at com.ibm.db2.jcc.c.gg.d(gg.java:2295)
        at com.ibm.db2.jcc.c.gg.W(gg.java:457)
        at com.ibm.db2.jcc.c.gg.executeUpdate(gg.java:440)
        at IO.Save.insertFile(Save.java:53)
        at IO.Save.main(Save.java:66)
Reply With Quote
  #6 (permalink)  
Old 01-30-08, 12:06
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
This is not the same error you had earlier. Here is the error help:

LCAD-->? sql204


SQL0204N "<name>" is an undefined name.

Explanation:

This error is caused by one of the following:

o The object identified by "<name>" is not defined in the
database.

o A data type is being used. This error can occur for the
following reasons:

- If "<name>" is qualified, then a data type with this name
does not exist in the database.

- If "<name>" is unqualified, then the user's function path
does not contain the schema to which the desired data type
belongs.

- The data type does not exist in the database with a create
timestamp earlier than the time the package was bound
(applies to static statements).

- If the data type is in the UNDER clause of a CREATE TYPE
statement, the type name may be the same as the type
being defined, which is not valid.

o A function is being referenced in one of:

- a DROP FUNCTION statement

- a COMMENT ON FUNCTION statement

- the SOURCE clause of a CREATE FUNCTION statement

If "<name>" is qualified, then the function does not
exist. If "<name>" is unqualified, then a function of
this name does not exist in any schema of the current function
path. Note that a function cannot be sourced on the COALESCE,
NULLIF, or VALUE built-in functions.



This return code can be generated for any type of database
object.

Federated system users: the object identified by "<name>" is not
defined in the database or "<name>" is not a nickname in a DROP
NICKNAME statement.

Some data sources do not provide the appropriate values for
"<name>". In these cases, the message token will have the
following format: "OBJECT:<data source> TABLE/VIEW", indicating
that the actual value for the specified data source is unknown.

The statement cannot be processed.

User Response:

Ensure that the object name (including any required qualifiers)
is correctly specified in the SQL statement and it exists. For
missing data type or function in SOURCE clause, it may be that
the object does not exist, OR it may be that the object does
exist in some schema, but the schema is not present in your
function path.

Federated system users: if the statement is DROP NICKNAME, make
sure the object is actually a nickname. The object might not
exist in the federated database or at the data source. Verify
the existence of the federated database objects (if any) and the
data source objects (if any).

sqlcode : -204

sqlstate : 42704

Andy
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On