alnasl
asked on
SQL Exception #1: java.sql.SQLException: User: qqrtcb, failed to be authenticated.
Hi!
I am new to this, so don't be too harsh ;-)
I'm invoking a servlet, that is supposed to build only a connection to a database and I get the error:
SQL Exception #1: java.sql.SQLException: User: qqrtcb, failed to be authenticated.
The server is remote. I have a sqlplus client on my computer and I am accessing the database manually without problems, using a username, password and a connect string - uname/passwd@connect_strin g. The username and the passowrd are the same as those I am using in the servlet.
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------
Here's the code:
package trip;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
import javax.sql.*;
import javax.naming.*;
public class TestDataSource extends HttpServlet
{
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, java.io.IOException
{
res.setContentType("text/h tml");
java.io.PrintWriter pick = new java.io.PrintWriter(res.ge tOutputStr eam());
try
{
Context ctx = new InitialContext();
if(ctx == null)
{
pick.println("JNDI problem. Can't get InitialContext. <br>");
}
else
{
pick.println("Road goes ever on, over rock and under tree<br>");
}
try
{
DataSource ds = (DataSource)ctx.lookup("jd bc/puck");
if(ds == null)
{
pick.println("One ring to rule them all...<br>" );
}
else
{
pick.println("Much that once was, is now lost!<br>");
}
try{
Connection con = ds.getConnection("qqrtcb", "bmw");
con.setAutoCommit(false);
PreparedStatement pstmt = con.prepareStatement("SELE CT id, name FROM stechnologies;");
ResultSet rs = pstmt.executeQuery();
if(rs != null)
{
pick.println("Frodo! It's Frodo Baggins!");
while(rs.next())
{
String id = rs.getString(1);
String name = rs.getString(2);
pick.println(id + " ; ; " + name);
}
}
else
{
pick.println("...and in the darkness bind them!");
}
rs.close();
pstmt.close();
con.close();
}
catch(SQLException sqle2)
{
pick.println("SQL Exception #1: " + sqle2 + "<br>");
}
}
catch(NamingException ne)
{
pick.println("<b>Naming Exception #1: </b>" + ne + "<br>");
}
}
catch(NamingException ne)
{
pick.println("Naming error #3: " + ne + "<br>");
}
pick.close();
}
public void init(ServletConfig cfg)
throws ServletException
{
super.init(cfg);
}
public void destroy()
{
super.destroy();
}
}
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- --------
The whole output that I get in the browser looks like that:
Road goes ever on, over rock and under tree
Much that once was, is now lost!
SQL Exception #1: java.sql.SQLException: User: qqrtcb, failed to be authenticated.
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ------
What do I do wrong?
any help would be greatly appreciated.
oh, and i forgot!
I've created the connection pool and the datasource in the WebLogic Administrator Console. So in my opinion they shouldn't be a problem.
thanks once more in advance.
al
I am new to this, so don't be too harsh ;-)
I'm invoking a servlet, that is supposed to build only a connection to a database and I get the error:
SQL Exception #1: java.sql.SQLException: User: qqrtcb, failed to be authenticated.
The server is remote. I have a sqlplus client on my computer and I am accessing the database manually without problems, using a username, password and a connect string - uname/passwd@connect_strin
--------------------------
Here's the code:
package trip;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
import javax.sql.*;
import javax.naming.*;
public class TestDataSource extends HttpServlet
{
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, java.io.IOException
{
res.setContentType("text/h
java.io.PrintWriter pick = new java.io.PrintWriter(res.ge
try
{
Context ctx = new InitialContext();
if(ctx == null)
{
pick.println("JNDI problem. Can't get InitialContext. <br>");
}
else
{
pick.println("Road goes ever on, over rock and under tree<br>");
}
try
{
DataSource ds = (DataSource)ctx.lookup("jd
if(ds == null)
{
pick.println("One ring to rule them all...<br>" );
}
else
{
pick.println("Much that once was, is now lost!<br>");
}
try{
Connection con = ds.getConnection("qqrtcb",
con.setAutoCommit(false);
PreparedStatement pstmt = con.prepareStatement("SELE
ResultSet rs = pstmt.executeQuery();
if(rs != null)
{
pick.println("Frodo! It's Frodo Baggins!");
while(rs.next())
{
String id = rs.getString(1);
String name = rs.getString(2);
pick.println(id + " ; ; " + name);
}
}
else
{
pick.println("...and in the darkness bind them!");
}
rs.close();
pstmt.close();
con.close();
}
catch(SQLException sqle2)
{
pick.println("SQL Exception #1: " + sqle2 + "<br>");
}
}
catch(NamingException ne)
{
pick.println("<b>Naming Exception #1: </b>" + ne + "<br>");
}
}
catch(NamingException ne)
{
pick.println("Naming error #3: " + ne + "<br>");
}
pick.close();
}
public void init(ServletConfig cfg)
throws ServletException
{
super.init(cfg);
}
public void destroy()
{
super.destroy();
}
}
--------------------------
The whole output that I get in the browser looks like that:
Road goes ever on, over rock and under tree
Much that once was, is now lost!
SQL Exception #1: java.sql.SQLException: User: qqrtcb, failed to be authenticated.
--------------------------
What do I do wrong?
any help would be greatly appreciated.
oh, and i forgot!
I've created the connection pool and the datasource in the WebLogic Administrator Console. So in my opinion they shouldn't be a problem.
thanks once more in advance.
al
ASKER
aye, that's exactly what i thought. but then, it works, when I do it in sqlplus. same username and password.
the code is full of try statements, so that i could narrow the error possibilities. and this is the only line, that could be faulty. but I don't see how.
what do you mean with these lines:
Context ctx = new InitialContext();
DataSource ds = (DataSource)ctx.lookup("jd bc/puck");
I don't see a difference to mine. do you mean, that I should pack the both lines in one try... catch block?
the code is full of try statements, so that i could narrow the error possibilities. and this is the only line, that could be faulty. but I don't see how.
what do you mean with these lines:
Context ctx = new InitialContext();
DataSource ds = (DataSource)ctx.lookup("jd
I don't see a difference to mine. do you mean, that I should pack the both lines in one try... catch block?
ASKER
i tried that. it made no difference. same error.
>:-(
>:-(
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Looks like your problem lays right here. You're not getting a connection to the database.
[
Context ctx = new InitialContext();
DataSource ds = (DataSource)ctx.lookup("jd
]