SQL Exception while connecting to oracle 11g from web application using jdbc?

You have a mis-match between the parameter types as declared by the login PL/SQL function, and the types you're setting in the Java. The boolean seems like the most likely candidate. Make sure the return type of login is really compatible with java booleans.

Up vote 0 down vote favorite share g+ share fb share tw.

I am getting SQL Exception. The following is my code, public DBConnect() { try { // Load the Oracle JDBC driver DriverManager. RegisterDriver(new oracle.jdbc.driver.OracleDriver()); // connect through driver conn = DriverManager.

GetConnection("jdbc:oracle:thin:@localhost:1521:orcl","system","system123"); // conn = DriverManager. GetConnection("jdbc:oracle:thin:@127.0.0.1:1521:XE","system","system123"); // create a statement object CallableStatement cstmt = null; String auth; try { cstmt = conn. PrepareCall("{?

= call login(?,? )}"); cstmt. RegisterOutParameter(1, java.sql.Types.

BOOLEAN); cstmt. SetString(2, "aniket"); cstmt. SetString(3, "aniket"); cstmt.execute(); auth = cstmt.

GetString(1); cstmt.close(); System.out. Println(auth); } catch (SQLException e) { e.printStackTrace(); } } catch (SQLException ex) { Logger. GetLogger(DBConnect.class.getName()).

Log(Level. SEVERE, null, ex); } catch(Exception e) { //system.out. Println(e.printStackTrace()); } } And the following is the stacktrace - java.sql.

SQLException: ORA-01403: no data found ORA-06512: at "SYSTEM. LOGIN", line 10 ORA-06512: at line 1 at oracle.jdbc.driver.DatabaseError. ThrowSqlException(DatabaseError.

Java:113) at oracle.jdbc.driver. T4CTTIoer. ProcessError(T4CTTIoer.

Java:331) at oracle.jdbc.driver. T4CTTIoer. ProcessError(T4CTTIoer.

Java:288) at oracle.jdbc.driver. T4C8Oall. Receive(T4C8Oall.

Java:754) at oracle.jdbc.driver. T4CCallableStatement. DoOall8(T4CCallableStatement.

Java:218) at oracle.jdbc.driver. T4CCallableStatement. ExecuteForRows(T4CCallableStatement.

Java:971) at oracle.jdbc.driver.OracleStatement. DoExecuteWithTimeout(OracleStatement. Java:1192) at oracle.jdbc.driver.

OraclePreparedStatement. ExecuteInternal(OraclePreparedStatement. Java:3415) at oracle.jdbc.driver.

OraclePreparedStatement. Execute(OraclePreparedStatement. Java:3521) at oracle.jdbc.driver.

OracleCallableStatement. Execute(OracleCallableStatement. Java:4612) at com.me.db.DBConnect.(DBConnect.

Java:57) at com.me.controller. PreLoginController. HandleRequestInternal(PreLoginController.

Java:25) at org.springframework.web.servlet.mvc. AbstractController. HandleRequest(AbstractController.

Java:153) at org.springframework.web.servlet.mvc. SimpleControllerHandlerAdapter. Handle(SimpleControllerHandlerAdapter.

Java:48) at org.springframework.web.servlet. DispatcherServlet. DoDispatch(DispatcherServlet.

Java:875) at org.springframework.web.servlet. DispatcherServlet. DoService(DispatcherServlet.

Java:809) at org.springframework.web.servlet. FrameworkServlet. ProcessRequest(FrameworkServlet.

Java:571) at org.springframework.web.servlet. FrameworkServlet. DoGet(FrameworkServlet.

Java:501) at javax.servlet.http.HttpServlet. Service(HttpServlet. Java:621) at javax.servlet.http.HttpServlet.

Service(HttpServlet. Java:722) at org.apache.catalina.core. ApplicationFilterChain.

InternalDoFilter(ApplicationFilterChain. Java:304) at org.apache.catalina.core. ApplicationFilterChain.

DoFilter(ApplicationFilterChain. Java:208) at org.apache.catalina.core. StandardWrapperValve.

Invoke(StandardWrapperValve. Java:240) at org.apache.catalina.core. StandardContextValve.

Invoke(StandardContextValve. Java:203) at org.apache.catalina.core. StandardHostValve.

Invoke(StandardHostValve. Java:164) at org.apache.catalina.valves. ErrorReportValve.

Invoke(ErrorReportValve. Java:108) at org.apache.catalina.valves.AccessLogValve. Invoke(AccessLogValve.

Java:558) at org.apache.catalina.core. StandardEngineValve. Invoke(StandardEngineValve.

Java:118) at org.apache.catalina.connector.CoyoteAdapter. Service(CoyoteAdapter. Java:379) at org.apache.coyote.

Http11. Http11Processor. Process(Http11Processor.

Java:242) at org.apache.coyote. Http11. Http11Protocol$Http11ConnectionHandler.

Process(Http11Protocol. Java:259) at org.apache.tomcat.util.net. JIoEndpoint$SocketProcessor.

Run(JIoEndpoint. Java:281) at java.util.concurrent. ThreadPoolExecutor$Worker.

RunTask(ThreadPoolExecutor. Java:886) at java.util.concurrent. ThreadPoolExecutor$Worker.

Run(ThreadPoolExecutor. Java:908) at java.lang.Thread. Run(Thread.

Java:619) The following is my PL/SQL function login - CREATE OR REPLACE FUNCTION login(p_uname IN varchar2, p_pword IN varchar2) RETURN String AS v_uname varchar2(30); v_pword varchar2(30); BEGIN SELECT uname, pword INTO v_uname, v_pword FROM user_account WHERE uname = p_uname AND pword = p_pword; IF (v_uname IS NULL OR v_pword IS NULL) THEN return 'Failed'; ELSE return 'Success'; END IF; END login; / java jdbc oracle11g link|improve this question edited Apr 18 '11 at 21:01 asked Apr 18 '11 at 18:46acoolguy787 100% accept rate.

After checking the stacktrace I thought that too but the function returns a boolean – acoolguy Apr 18 '11 at 19:14 1 @acoolguy: Ah, OK. I seem to recall that Oracle's JDBC driver doesn't actually support the PL/SQL BOOLEAN type. Your error suggests that they still haven't fixed this.

– skaffman Apr 18 '11 at 19:23 now I have changed my login. Sql now it returns a string, I'll edit the file above. Now the error is different, the error is no data found though I have inserted a row in the user_account table – acoolguy Apr 18 '11 at 20:14.

As mentioned by skaffman, the Oracle JDBC driver doesn't support PL/SQL boolean type. So I changed the return type to varchar. One more critical thing missing in my PL/SQL code was the exception handling in case of 0 rows returned i.e.

NO_DATA_FOUND Added that exception in the PL/SQL function login and changed the location of Returning 'False' to exception section as IF NO_DATA_FOUND THEN Return 'False.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions