JDBC connection to db2 
Author Message
 JDBC connection to db2

Hello!

I am trying to connect to db2 from servlet, and I am using syntax
from ibm's site, like:

Class.forName("COM.ibm.db2.jdbc.net.DB2Driver").newInstance();
Connection conn = DriverManager.getConnection( str_url,str_user,str_pass );

where str_url  = "jdbc:db2://192.168.1.1:6789/sample";
and on port 6789 is JDBC applet server, and DB is sample database.

String str_user = "db2admin" and pass is valid.

I am trying to execute following query:

"SELECT * FROM employee"

and I am getting following error:
COM.ibm.db2.jdbc.net.DB2Exception: [IBM][CLI Driver][DB2/NT]
 SQL0204N "DB2ADMIN.EMPLOYEE" is an undefined name. SQLSTATE=42704

if I write "SELECT * FROM sample.employee"
I get:
COM.ibm.db2.jdbc.net.DB2Exception: [IBM][CLI Driver][DB2/NT]
SQL0204N "SAMPLE.EMPLOYEE" is an undefined name. SQLSTATE=42704

Please help....

Darko



Sat, 23 Aug 2003 21:16:02 GMT
 JDBC connection to db2

I forgot to write that from control center I can see that
sample database and employee table exists
(one explanation ruled out)

Darko



Sat, 23 Aug 2003 21:28:36 GMT
 JDBC connection to db2

Quote:
> I am trying to execute following query:

> "SELECT * FROM employee"

> and I am getting following error:
> COM.ibm.db2.jdbc.net.DB2Exception: [IBM][CLI Driver][DB2/NT]
>  SQL0204N "DB2ADMIN.EMPLOYEE" is an undefined name. SQLSTATE=42704

> if I write "SELECT * FROM sample.employee"
> I get:
> COM.ibm.db2.jdbc.net.DB2Exception: [IBM][CLI Driver][DB2/NT]
> SQL0204N "SAMPLE.EMPLOYEE" is an undefined name. SQLSTATE=42704

Solved.

{*filter*}.... First steps created scheme for me, and asked for it.

:-))))



Sat, 23 Aug 2003 23:06:24 GMT
 JDBC connection to db2

Quote:

>I am trying to execute following query:

>"SELECT * FROM employee"

>and I am getting following error:
>COM.ibm.db2.jdbc.net.DB2Exception: [IBM][CLI Driver][DB2/NT]
> SQL0204N "DB2ADMIN.EMPLOYEE" is an undefined name. SQLSTATE=42704

>if I write "SELECT * FROM sample.employee"
>I get:
>COM.ibm.db2.jdbc.net.DB2Exception: [IBM][CLI Driver][DB2/NT]
>SQL0204N "SAMPLE.EMPLOYEE" is an undefined name. SQLSTATE=42704

What schema is EMPLOYEE in?  I run:

db2 select tabschema, tabname from syscat.tables where tabname = 'EMPLOYEE',
and I get:

[Major reconstruction of the output to make it look nice.]

TABSCHEMA  TABNAME
---------  -------
DARIN      EMPLOYEE

Thus, to select all employees, I need to do:

db2 select * from darin.employee

Especially if I'm not "DARIN" (you're "DB2ADMIN" it seems).  There are other
solutions, but I find this one to work for me.



Sun, 24 Aug 2003 00:59:15 GMT
 JDBC connection to db2

Quote:

cut
> What schema is EMPLOYEE in?  I run:

> db2 select tabschema, tabname from syscat.tables where tabname =
'EMPLOYEE',
> and I get:

> [Major reconstruction of the output to make it look nice.]

> TABSCHEMA  TABNAME
> ---------  -------
> DARIN      EMPLOYEE

> Thus, to select all employees, I need to do:

> db2 select * from darin.employee

> Especially if I'm not "DARIN" (you're "DB2ADMIN" it seems).  There are
other
> solutions, but I find this one to work for me.

Darin, thank you, it works!

Darko



Sun, 24 Aug 2003 15:01:19 GMT
 JDBC connection to db2



Quote:
> I am trying to execute following query:
> "SELECT * FROM employee"
> and I am getting following error:
> COM.ibm.db2.jdbc.net.DB2Exception: [IBM][CLI Driver][DB2/NT]
>  SQL0204N "DB2ADMIN.EMPLOYEE" is an undefined name. SQLSTATE=42704

try administrator.employee

Jan



Fri, 29 Aug 2003 19:14:08 GMT
 JDBC connection to db2
I am assuming that you are using the DB2 SAMPLE database.
In that case, you should qualify the table "employee" with the schema
where this table was created under. Typically this should be the same
as the userid who created the SAMPLE database.

When you normally do a select like below, DB2 searches for a
table with table name <your-userid>.<tablename>. Thus when doing
operations on tables which are not in the same schema as your
userid or the default schema, you have to explicitly qualify all
tables. This is true for all database objects (tables, indexes, views etc).

Cheers!
Tyronne


Quote:



> > I am trying to execute following query:
> > "SELECT * FROM employee"
> > and I am getting following error:
> > COM.ibm.db2.jdbc.net.DB2Exception: [IBM][CLI Driver][DB2/NT]
> >  SQL0204N "DB2ADMIN.EMPLOYEE" is an undefined name. SQLSTATE=42704

> try administrator.employee

> Jan



Mon, 22 Sep 2003 20:14:36 GMT
 
 [ 7 post ] 

 Relevant Pages 

1. jdbc connection to DB2 5.1.2 on os/390

2. JDBC connections to DB2/400 (AS/400e)

3. JDBC connection to DB2 on OS/390 from Solaris

4. Problems with JDBC connections to DB2 6.1 on AIX

5. Newbie question: jdbc connection to db2

6. Differences between COM.ibm.db2.jdbc.app.DB2Driver and COM.ibm.db2.jdbc.net.DB2Driver

7. DB2 Ver 7.1 JDBC Connection Pooling problem

8. jdbc connection string to db2/400

9. Urgent! DB2 jdbc connection error

10. JDBC Connection to Mainframe DB2

11. JDBC - DB2 connection

12. DB2/400 JDBC Connections


 
Powered by phpBB® Forum Software