Link to home
Start Free TrialLog in
Avatar of Rakafkaven
Rakafkaven

asked on

newbie: JDBC query exception: "SQL0204 *tablename* in *username* type FILE not found"

This error doesn't make sense to me, and makes me think that I'm doing something silly when connecting to my database.  Everything compiles just fine, and the connection seems to go fine (as far as I can tell) until my retrieveData procedure throws an exception that says "BLLOPER in MYUSERNAME type *FILE not found".  BLLOPER is the table name targeted by my SELECT query, and MYUSERNAME is the username I use in the Connection string to log in.  I wouldn't expect to find a table in a username.  I'm not sure why Java does.  Probably something to do with my Connection string, but if I really knew what I was doing, I wouldn't be begging for help here.

Code is cribbed heavily from:http://www.javacamp.org/moreclasses/jdbc/jdbc.html
Connection string partially derived from: http://publib.boulder.ibm.com/infocenter/hod9help/index.jsp?topic=/com.ibm.hod9.doc/help/db_url.html

import java.sql.*;

public class TestDBDriver {
static Connection con;
static Statement stmt;
static ResultSet rs;
static DatabaseMetaData dmd;

public static void main(String[] args) {
      loadDriver();
      makeConnection();
      retrieveData();
} //main


static void loadDriver() {
try {
      Class.forName("com.ibm.as400.access.AS400JDBCDriver");
} catch(java.lang.ClassNotFoundException e) {
      System.err.print("ClassNotFoundException: ");
      System.err.println(e.getMessage());
} //try
} //loadDriver

static void makeConnection() {
String url = "jdbc:as400://10.2.2.11;database name=MYDBNAME";
String user = "MYUSERNAME";
String pwd = "MYPWD";
try {
      con = DriverManager.getConnection(url, user, pwd);
} catch(SQLException ex) {
      System.err.println("database connection: " + ex.getMessage());
} //try
} //makeConnection

static void retrieveData() {
try {
String opSQL = "SELECT ODESC FROM BLLOPER";
stmt = con.createStatement();
rs = stmt.executeQuery(opSQL);
while (rs.next()) {
      String s = rs.getString("ODESC");
      System.out.println(s);
} //while
} catch(SQLException exrd) {
      System.err.println("retrieve failed: " + exrd.getMessage());
} //try
} //retrieveData
} //class
Avatar of Rakafkaven
Rakafkaven

ASKER

Changing opSQL to read "SELECT ODESC FROM MYDBNAME.BLLOPER" changes my error message to "[SQL0204] BLLOPER IN MYDBNAME type *FILE not found", which at least makes English-language sense to me:  can't find table in database.  Not sure why that changes anything, or why the database name in my Connection url didn't do this anyway... but whatever.

Still, a new and exciting variation on the same error is not a solution.  Any input would be greatly appreciated.
Fixed.  Thats the error you get when you spell your table name incorrectly.  Painfully obvious, but the weird mention of the username in the error was throwing me.  Anyone who can explain why that happened still gets the points.
Avatar of hoomanv
> Thats the error you get when you spell your table name incorrectly
each table will be stored as a file also on some DB there is a separate file for table schema.
this is whay you get *tablename* in *username* type FILE not found
also it could be spelled that the there is no table with the specified name in this username account

ASKER CERTIFIED SOLUTION
Avatar of Siva Prasanna Kumar
Siva Prasanna Kumar
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks everyone!