GeeCON Prague 2014*
The moose likes JDBC and the fly likes unable to connect to database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » JDBC
Bookmark "unable to connect to database" Watch "unable to connect to database" New topic
Author

unable to connect to database

Kumar sundar
Greenhorn

Joined: Jun 13, 2008
Posts: 9
Hi..
I have jndi set up for JBOSS server.
I am gettig the below exception:

2008-06-16 13:58:58,950 ERROR [STDERR] com.ibm.db2.jcc.b.SqlException: DB2 SQL error: SQLCODE: -551, SQLSTATE: 42501, SQLERRMC: RFAPP;SELECT;DA01.BR_PROV_CLAIM_TB
2008-06-16 13:58:58,951 ERROR [STDERR] at com.ibm.db2.jcc.b.id.e(id.java:1640)
2008-06-16 13:58:58,951 ERROR [STDERR] at com.ibm.db2.jcc.b.id.a(id.java:1229)
2008-06-16 13:58:58,952 ERROR [STDERR] at com.ibm.db2.jcc.b.id.a(id.java:1215)
2008-06-16 13:58:58,952 ERROR [STDERR] at com.ibm.db2.jcc.c.fb.h(fb.java:142)
2008-06-16 13:58:58,952 ERROR [STDERR] at com.ibm.db2.jcc.c.fb.a(fb.java:43)
2008-06-16 13:58:58,952 ERROR [STDERR] at com.ibm.db2.jcc.c.s.a(s.java:30)
2008-06-16 13:58:58,952 ERROR [STDERR] at com.ibm.db2.jcc.c.wb.g(wb.java:152)
2008-06-16 13:58:58,952 ERROR [STDERR] at com.ibm.db2.jcc.b.id.n(id.java:1209)
2008-06-16 13:58:58,952 ERROR [STDERR] at com.ibm.db2.jcc.b.id.a(id.java:1889)
2008-06-16 13:58:58,952 ERROR [STDERR] at com.ibm.db2.jcc.b.id.a(id.java:517)
2008-06-16 13:58:58,952 ERROR [STDERR] at com.ibm.db2.jcc.b.id.executeQuery(id.java:501)
2008-06-16 13:58:58,952 ERROR [STDERR] at org.jboss.resource.adapter.jdbc.WrappedStatement.executeQuery(WrappedStatement.java:171)

MY JDBC CODE in SERVLET IS AS BELOW:

Connection con2= necon.getConnection();
String st="after cobnnection";
out.println(st);
java.sql.Statement stmt2=con2.createStatement();
st="after stmt";
out.println(st);
java.sql.ResultSet rs=stmt2.executeQuery(sql);
st="after rs";
out.println(st);



String com1="before while";
out.println(com1);
int caseID=0;
String parish="";
String cnslr="";
while(rs.next()){
out.println(com1);
caseID=rs.getInt("CASE_MASTER_ID");
parish=rs.getString("CURRENT_PARISH");
cnslr=rs.getString("CNSLR");
}
out.println(com1);

out.println(caseID);
out.println(parish);
out.println(cnslr);

Dows anybody have any ide about the
org.jboss.resource.adapter.jdbc.WrappedStatement.executeQuery(WrappedStatement.java:171) error in JBOSS
Muhammad Saifuddin
Ranch Hand

Joined: Dec 06, 2005
Posts: 1321

com.ibm.db2.jcc.b.SqlException: DB2 SQL error: SQLCODE: -551, SQLSTATE: 42501, SQLERRMC: RFAPP;SELECT;DA01.BR_PROV_CLAIM_TB


it looks like the error in SQL query to me ?

can you share the query.


Saifuddin..
[Blog][Linkedin] How To Ask Questions On JavaRanch My OpenSource
Kumar sundar
Greenhorn

Joined: Jun 13, 2008
Posts: 9
The Query is as below:

String sql = "select * from "+necon.getAlias()+".BR_PROV_CLAIM_TB;";

getAlias returns the value DA01.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

When I did a Google search for "SQLSTATE: 42501", pretty much every link that it returned said something about the authorization ID not having the privilege to do that query.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: unable to connect to database