Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Oracle Invalid Column Name Error in JSP

843854May 30 2003 — edited Jun 2 2003
I was wondering if anyone could provide some help. I am new to JSP, Beans and Oracle and I am getting a java.sql.SQLException: ORA-00904: invalid column name error when I run the JSP below. The Java Bean's code it is referencing is also included and this bean is just storing information from the server from a previous login page.
Eventually I need to display more columns from the database using this JSP, but since I can even get this one working, I am at a loss!
PLEASE HELP!!!!
I have even tried to replace the beans reference in the sql with just a login and password I know exists in the database! Same error... Help!
I am running Tomcat and Oracle 9i!




<!--
Assign-->

<html>
<head>
<title>Student Signon on page</title>
</head>
<body bgcolor="#FDF5E6">
<h1 align="center">>Student Signon on page</h1>

<%@ page import="java.sql.*" %>
<%@ page import="BeanAs2.Bean5b" %>
<%
String driverClassString = "oracle.jdbc.driver.OracleDriver";
String driverConnectString;
driverConnectString = "jdbc:oracle:thin:@midas2:1521:globaldb";
String user = "system";
String passwd = "manager";
%>
<jsp:useBean id="Bean5b" class="BeanAs2.Bean5b" />

<jsp getProperty id = "Bean5b" property = "login" />
<jsp getProperty id = "Bean5b" property = "pswd" />
<%

Connection connection = null;

try {
Class.forName(driverClassString);
connection = DriverManager.getConnection(driverConnectString, user, passwd);
}
catch (Exception e) {
out.println("Cannot close connect to database!"+e);
}

if (connection != null) {

String login =Bean5b.getpassword();
String pswd =Bean5b.getStudentlogin();
String sql = "SELECT studentinfo.familyname FROM STUDENTINFO WHERE studentinfo.username='login' AND studentinfo.password='pswd';";
try { // execute the query
//SELECT studentinfo.familyname FROM STUDENTINFO WHERE studentinfo.username='s40079703' AND studentinfo.password='p4007swd'
Statement stmt = connection.createStatement();
ResultSet rst;

rst = stmt.executeQuery(sql);

// Fetch the query result, and dispaly them in a table
while (rst.next()) {
%>

<tr>
<td> <%= rst.getString("system.teaching.code") %> </td>
</tr>
<%
}

stmt.close();
connection.close();
} catch(Exception e) {
out.println("Cannot fetch data from database!"+e);
};
}
%>

</body></html>

package BeanAs2;

import java.util.*;

public class Bean5b {

// all variables must not be public in a bean

private String Studentlogin;
private String password;

public String getStudentlogin() {
return this.Studentlogin;
}

public String getpassword() {
return this.password;
}

public void setStudentlogin(String login) {
this.Studentlogin = login;
}

public void setpassword(String pswd) {

this.password = pswd;
}


}

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 30 2003
Added on May 30 2003
4 comments
448 views