"invalid column name" using resultset.getString()???

I had a sql query against oracle db:
select table1.field1, table1.field2, table2.field3
from table1, table2
where table1.field1=table2.field1;
i got a valid resultset and i can enum the resultset by rs.getString(colnum). However, when i try to use rs.getString(table1.field1), i get a sql exception: "invalid column name". has anybody seen this before?
TIA

Hi,
You can also modify your query and use the keyword "As" to give your fields another name :
select user.name as userName, admin.name as adminName
from user, admin
rs.getString("userName");
rs.getString("adminName");

Similar Messages

  • Column exist but ResultSet.getString(String) return invalid column name

    With oracle 7 db the ResultSet.getString(String) works fine but after the upgrade to oracle 8 db it return invalid column name. ResultSet.getString(int) method works fine.
    Is this a bug in the driver?
    Thanks
    -Reda

    Yes I'm 100 % sure that the columns exist.
    -RedaWell then maybe it's a bug in the Oracle driver. Lord knows it wouldn't be the first time that's happened.

  • Use of NOT IN leads to an invalid column name error

    The query works just fine when placed directly into sql plus
    The query works, called from a Java using an Oracle Statement, ONLY IF I remove the NOT.
    However, with NOT it chokes, and gives me this:
    selQ=select lenum, zeugn from stock_rpt where lenum NOT in ('X12345', 'X23456')
    Could Select or Read Selected data
    java.sql.SQLException: Invalid column name
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:208)
    at oracle.jdbc.driver.OracleStatement.getColumnIndex(OracleStatement.java:3319)
    at oracle.jdbc.driver.OracleResultSetImpl.findColumn(OracleResultSetImpl.java:1926)
    at oracle.jdbc.driver.OracleResultSet.getString(OracleResultSet.java:1515)
    at ecspack.StockRpt.selRecsByQ(StockRpt.java:172)
    at ecspack.StockRpt.selByDiff(StockRpt.java:261)
    at teste.main(teste.java:40)
    The column does have an index.
    The above is my simplified test query, I am using to narrow down the problem.
    SelQ is the value of the Select String.
    Really I want to do something like this:
    select x1, x2 from tableX where x1 NOT IN (select y1 from tableY)
    I know I can just compare records one at a time, but I would rather not, if there is a way to make NOT IN work.
    Thank you

    Hi Eileen Keeney ,
    may be you can use prepared statement but beware of sql injection
    selQ=select lenum, zeugn from stock_rpt where lenum NOT in ('X12345', 'X23456')
    Try :
    selQ=select lenum, zeugn from stock_rpt where lenum NOT in (?, ?)
    Then try running it with this fixed parameter binding:
    prest.setString(1, "X12345");
    prest.setString(2, "X23456");

  • Invalid column name in query string - using Format function

    In my post just before this one the problem was solved for writing a query string using a date range. The rest of the query string includes the same date field (Call_Date) but formatted as 'MMM-YY'. I get an invalid column name error when I add this field to the query string. Here is the rest of the query string:
    strSql = "SELECT Format(CALL_DATE,'mmm-yy'), " _
    & "HOME_REGION FROM CCC2.CASE_EPRP " _
    & "WHERE (HOME_REGION = 'NCR') AND " _
    "(CALL_DATE >= to_date( '1/1/2002', 'MM/DD/YYYY' )" _
    & "AND CALL_DATE <= to_date( '2/28/2003', 'MM/DD/YYYY' ))"
    In the Access Query tool I can include this field
    Format(CALL_DATE,'mmm-yy')
    and the query runs fine (I just need to make it dynamic using ADO). But in my ADO query string above, I get the invalid column name error. Is there a way I can include
    Format(CALL_DATE,'mmm-yy')
    in my ADO query string? I appologize for not being more familiar with Oracle Sql. Any help greatly appreciated.
    Thanks again,
    Rich

    Thank you very much for your reply. I think I'm getting closer to the solution. Just I got an error message
    "date format not recognized"
    when I add "to_char( call_date, 'mmm-yy' )" to the query string. I tried using all uppercase, but that did not make a difference. Do I need to use to_date inside the to_char maybe?
    to_char(to_date(call_date, 'mmm/yy'), 'mmm-yy')
    Thanks again for your help.
    Rich

  • SSMS 2012: Using CTE in a query - Invalid column name 'EmployeeID' !!??

    Hi all,
    From Page 88 of the Book "SQL Programming & Database Design Using Microsoft SQL Server 2012" written by Kalman Toth, I copied the following code of Using CTE in a query:
    -- CTETest2.sql /// saved in C:\My Documents\SQL Server Management Studio\
    ----Page 88 of Book by Toth === Using CTE in a query ----- 13 March 2015
    --Using CTE in a query
    ;WITH CTE (SalesPersonID, NumberOfOrders, MostRecentOrderDate)
    AS (SELECT SalesPersonID, COUNT(*), CONVERT(date, MAX(OrderDate))
    FROM Sales.SalesOrderHeader GROUP BY SalesPersonID )
    --Start of outer (main) query
    SELECT E.EmployeeID,
    OE.NumberOfOrders AS EmpOrders,
    OE.MostRecentOrderDate AS EmpLastOrder,
    E.ManagerID,
    OM.NumberOfOrders AS MgrOrders,
    OM.MostRecentOrderDate AS MgrLastOrder
    FROM HumanResources.Employee AS E
    INNER JOIN CTE AS OE ON E.EmployeeID = OE.SalesPersonID
    LEFT OUTER JOIN CTE AS OM ON E.ManagerID = OM.SalesPersonID
    In my SQL Server 2012 Management Studio, I executed this set of code and I got the following fatal error:
    Msg 207, Level 16, State 1, Line 16
    Invalid column name 'EmployeeID'.
    I have no clues why I got this error message in this .sql trial of my second practice in doing CTE.  Please kindly help and let me know where I made mistake and how to resolve this problem.
    Thanks in advance,
    Scott Chang

    Hi scott_morris-ga, Thanks for your nice response.
    I changed EmployeeID to BusinessEntityID as you pointed out and executed the revised code:
    -- CTETest2.sql /// saved in C:\My Documents\SQL Server Management Studio\
    ----Page 88 of Book by Toth === Using CTE in a query ----- 13 March 2015
    --Using CTE in a query
    ;WITH CTE (SalesPersonID, NumberOfOrders, MostRecentOrderDate)
    AS (SELECT SalesPersonID, COUNT(*), CONVERT(date, MAX(OrderDate))
    FROM Sales.SalesOrderHeader GROUP BY SalesPersonID )
    --Start of outer (main) query
    SELECT E.BusinessEntityID,
    OE.NumberOfOrders AS EmpOrders,
    OE.MostRecentOrderDate AS EmpLastOrder,
    E.ManagerID,
    OM.NumberOfOrders AS MgrOrders,
    OM.MostRecentOrderDate AS MgrLastOrder
    FROM HumanResources.Employee AS E
    INNER JOIN CTE AS OE ON E.BusinessEntityID = OE.SalesPersonID
    LEFT OUTER JOIN CTE AS OM ON E.ManagerID = OM.SalesPersonID
    I got 2 new error messages:
    Msg 207, Level 16, State 1, Line 17
    Invalid column name 'ManagerID'.
    Msg 207, Level 16, State 1, Line 12
    Invalid column name 'ManagerID'.
    I have no ideas what should be used to replace 'ManagerID' in my revised code. Could you please help again and give me the right thing to replace the 'ManagerID'? By the way, where in the AdventureWorks do you find the right things?  Please enlighten
    me in this matter.
    Many Thanks again,  Scott Chang 

  • Using oracle thin driver with to_char gives invalid column name

    select x,y,z, to_char(event_time,'YYYY-MMM-DD') from eventtable;
    if i execute the above query using oracle thin driver it gives me invalid column name. It works fine if i use weblogic driver. So what could be the problem ???
    thanks.

    Sorry , forgot to add that 'YYYY-MM-DD' or 'YYYY-Month-DD' or 'Year-MM-DD' or 'Year-Month-DD' are also allowed(please cheek also for other combinations), not 'YYYY-MMM-DD'.
    Thanks

  • Using "$" character with Oracle; getting "invalid column name"

    I am running the following query against an Oracle database:
    select price from my_table
    where index_name = 'CGPR_C$'
    and settlement_date = to_date('02/19/2001','MM/DD/YYYY')
    The query runs fine in TOAD.
    If I run this query from my java code, I get an "invalid column name" exception.
    If I take out the "$" character, the query runs fine.
    I've tried inserting the "$" in as unicode, escaping out the character, ||chr(36)||, and nothing works.
    Please help!
    Ashley

    Look up your Oracle SQL documentation and find out how to use column names that would otherwise be invalid. Some databases allow you to put column names, table names, and so on in square brackets (e.g. [CGPR_C$]) but I don't know Oracle's syntax.

  • ORA-00904: invalid column name in select query by using abstract datatype

    Hi,
    I had created abstract datatype as PERSON_TY and ADDRESS_TY ,
    after inserting the record . i'm tryng to select the column but i got the error , even i refferd all those thing. they are given that same please look this finde me a result.
    SQL> DESC PERSON_TY
    Name Null? Type
    NAME VARCHAR2(25)
    ADDRESS ADDRESS_TY
    SQL> DESC ADDRESS_TY
    Name Null? Type
    STREET VARCHAR2(30)
    CITY VARCHAR2(25)
    STATE CHAR(2)
    COUNTRY VARCHAR2(15)
    SQL> SELECT * FROM EMPLOYE
    2 ;
    EMP_CODE
    PERSON(NAME, ADDRESS(STREET, CITY, STATE, COUNTRY))
    10
    PERSON_TY('VENKAT', ADDRESS_TY('112: BLUE MOUNT', 'CHENNAI', 'TN', 'INDIA'))
    20
    PERSON_TY('SRINI', ADDRESS_TY('144: GREEN GARDEN', 'THAMBARAM', 'TN', 'INDIA'))
    SQL> SELECT PERSON.NAME FROM EMPLOYE
    2 ;
    SELECT PERSON.NAME FROM EMPLOYE
    ERROR at line 1:
    ORA-00904: invalid column name
    regards
    venki

    SELECT PERSON.NAME FROM EMPLOYEIf you look in the documentation, you will see that we need to alias the table in order to make this work:
    select e.person.name from employees e
    /Cheers, APC
    Blog : http://radiofreetooting.blogspot.com

  • Invalid Column Name on select from materialized view?

    Hey all, I have created this materialized view for my java to select from. For some reason when I try to select from it, I get invalid column name. Here is my mat view statement in its simplest form:
    create materialized view mv_pgridtcevcluster_property as
    select distinct clustername_ as "OBJECT_ID", CLUSTERNAME_, LICENSEMODE_
    from p_gridtcevcluster p
    order by clustername_;
    Now when I run my select statement from jdbc:
    SQL: select object_id from MV_PGRIDTCEVCLUSTER_PROPERTY
    java.sql.SQLException: Invalid column name
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:208)
         at oracle.jdbc.driver.OracleStatement.getColumnIndex(OracleStatement.java:3319)
         at oracle.jdbc.driver.OracleResultSetImpl.findColumn(OracleResultSetImpl.java:1926)
         at oracle.jdbc.driver.OracleResultSet.getString(OracleResultSet.java:1515)
         at com.mchange.v2.c3p0.impl.NewProxyResultSet.getString(NewProxyResultSet.java:3342)
         at historian.objects.mgmt.udrManagerTest.gatherObjects(udrManagerTest.java:73)
    Anyone have issues with this before? It seems to throw the error sporatically, any help would be much appreciated!
    Regards,
    TimS
    Edited by: TimS on Mar 30, 2009 1:54 PM
    Nevermind, figured it out. Was using wrong column name identifier when picking values from resultset.

    Since you have "OBJECT_ID" in quotes, Oracle stores the column name literally and case sensitively, and the column name must be capitalized when referenced.
    From a regular sql*plus window, try
    select object_id from mv_pgridtcevcluster_property;
    select OBJECT_ID from mv_pgridtcevcluster_property;
    select "OBJECT_ID" from mv_pgridtcevcluster_property;What is the result from each of them?

  • Invalid column name - fixed by inserting a carriage return - Why?

    I'm writing some JSP pages and am executing a statement that retrieves values from three tables.
    When executing the statement I receive the error
    java.sql.SQLException: Invalid column name
    I just want to state here that ALL the column names are definitely correct. I attempted to isolate the problem using my SQL*Plus Interface.
    When copying and pasting the SQL that was used (I put the SQL statement into the HTML to allow me to do this) into SQL*Plus it also come up with the error. I found that if I broke up the statement it would run. Specifically if I placed a carriage return (by hitting enter) prior to the 'A' of the AND operator and then copied and pasted into SQL*Plus it would work!
    I thought the problem was related to bad syntax in the outer join operator. But removal of the outer join operator and making it a EQUI JOIN situation still gave the same results. I tried the use of brackets to 'help' the DB engine figure it out - silly I know, but it didn't work anyway :(
    I've tried this out on UNIX in SQL*Plus where the query was on one line and it worked fine. I've tried it on Oracle 8.1.5 SQL*Plus & Oracle 8.1.7 SQL*Plus on Win2000 and WinNT and no go.
    It has also been tested on an Oracle 7.3.4 DB and no go either.
    Remember I'm only using SQL*Plus to find out why it is not working - I'm actually attempting to execute this via JDBC (classes12.zip Oracle9 version) in my JavaBean. I can't place a carriage return to 'fix' the problem, and I'm assuming that I shouldn't either.
    I've pasted the SQL below (both non-working and working versions). I was going to paste the output of DESC on the associated tables should you too would rule out a mispelled column name, but I didn't want to put anyone off with a long post.
    If you can provide any advice I would be very appreciative.
    Darren James
    Show Me Technology
    SQL> SELECT UNIT.Asset_Number,Model,PERSON.Novell_User_Name FROM
    UNIT, UNIT_USERS, PERSON
    2 WHERE UNIT.Hardware_Reference_Number =
    UNIT_USERS.Hardware_Reference_Number(+) AND UNIT_USERS
    .Novell_User_Name = PERSON.Novell_User_Name (+) ORDER BY Make,
    Model, Asset_Number,Serial_Number,
    UNIT.Hardware_Reference_Number,Unit_Type,PERSON.Last_Name,PERSON.Fi
    rst_Name,PERSON.Novell_User_Name;
    3 /
    WHERE UNIT.Hardware_Reference_Number =
    UNIT_USERS.Hardware_Reference_Number(+) AND UNIT_USERS.Novel
    ERROR at line 2:
    ORA-00904: invalid column name
    REM -- Using the one with an return prior to the AND
    SQL> SELECT UNIT.Asset_Number,Model,PERSON.Novell_User_Name FROM
    UNIT, UNIT_USERS, PERSON
    2 WHERE UNIT.Hardware_Reference_Number =
    UNIT_USERS.Hardware_Reference_Number(+)
    3 AND UNIT_USERS.Novell_User_Name = PERSON.Novell_User_Name
    (+) ORDER BY Make, Model,
    4 Asset_Number,Serial_Number,
    5
    UNIT.Hardware_Reference_Number,Unit_Type,PERSON.Last_Name,PERSON.Fi
    rst_Name,PERSON.Novell_User_
    Name;
    ASSET_NUMBER
    MODEL
    NOVELL_USE
    10023445
    desktop raider
    tabisho
    10023445
    desktop raider
    pjblee
    100349864
    VEi8
    SQL>

    Ok. I feel ashamed that the answer was so simple and not the
    problem I thought it was. But in the interests of perhaps
    preventing someone else doing the same silly thing....
    The error was caused by using a wrong name when 'getting' the
    values int the return ResultSet object. (eg using getString
    ("s.Some_Name") when it should have been getString
    ("s.Another_Name").
    Interestingly the error did occur in one of our SQL*Plus
    versions. Why we still are not sure, but since this was a silly
    error on my part, I'm sure a similarly silly reason will be the
    cause there two.
    I appreciate those who responded though. It is a great resource.
    Darren James
    I'm just guessing here, but could it be some sort of a size thing? Could it be that, if you don't break up line 2, somehow
    it gets truncated or wrapped at an inappropriate place? To test
    this theory, you might try putting the carriage return in front
    of the ORDER BY, instead of in front of the AND, and see if it
    has the same effect. If you do get it figured out, please
    satisfy our curiosity and let us know.

  • X.column.getStringVal() throws "invalid column name", works in SQL*Plus.

    The subject sums it up pretty well... I have a query that works fine from SQL*Plus, but throws a JDBC exception with "ORA-00904 invalid column name" if I create a PreparedStatement from it and call executeQuery().
    The query itself is substantially similar to:
    SELECT foo, t.bar.getStringVal() from some_table t
    where "Some table" is an oracle 9i table, "foo" is a varchar2 column, and "bar" is a column that used to be varchar2 before I dropped and re-created the table with an xmltype column instead. "t" is an alias for the table that I didn't used to need (since it's only one table), but apparently is required for getStringVal() to work.
    ... And, of course, .getStringVal() is being used as a convenient way to treat technically LOB-like xmltype columns as big ersatz varchar2 columns so I won't have to screw around with stream i/o just to read a 4,001-byte value into a String ;-)
    I'm using the ojdbc14.jar thin driver and a fairly recent j2sdk (1.4.1_02, I think). I made a point of anihilating every copy of classes12.zip on my PC just to make sure it wasn't lurking in a classpath somewhere to screw things up.
    Strangely enough, it DOES work from within Netbeans' database explorer (itself connecting to the same Oracle database using the ojdbc14.jar thin driver).
    For the sake of being comprehensive, here's an example of the actual JDBC code that won't work:
    public ResultSet doQuery(Connection conn, int val) throws SQLException {
    String sql = "SELECT foo, t.bar.getStringVal() from some_table t where anothercolumn = ?";
    PreparedStatement sth = conn.prepareStatement(sql);
    sth.setInt(1, val);
    ResultSet rs = sth.executeQuery();
    // everything past this point is moot,
    // because sth.executeQuery throws an exception...
    // however, the ResultSet would ultimately be
    // returned to the method's caller, and
    // its values read using getString(fieldname)
    // including 'bar', the xmltype field...

    OK, this particular problem was my fault. The original table was on a server running 8i. To spare myself the grief of having to deal with CLOBs on 8i's terms and take advantage of 9i's new conveniences for handling them, I created a new table on our other server that's running 9i and updated the app's config settings to reflect the new server. Unfortunately, I forgot that the debugging/testing main() method had the URL of the old database hardcoded (it was written before the rest of the class). Ergo... it was still looking at the old database. Oops. (*blush*).

  • Invalid Column Name Error : JDBC Driver 9.2.* accessing Oracle 7.3.*

    We are migrating a web app from JDK 1.2 environment to a JDK 1.5 server enviroment. Previously the web app used the classes12.zip package, now we are using ojdbc14.jar for the new server environment.
    Now this particular app uses Oracle7 Server Release 7.3.3.6.0. to retrieve data. I would run a query and get the result set explicitly using the column name.
    sql_query = " SELECT DISTINCT(INSIDE_SALES_TEAM_NAME) AS D_INSIDE_SALES_TEAM_NAME FROM AGED_INVENTORY" ;
    rset.getString("D_INSIDE_SALES_TEAM_NAME");
    However, after migration to ojdc14.jar (using Oracle JDBC driver 9.2.0.8.0) I can't retrieve the resultset in the above-mentioned fashion. I will always get
    java.sql.SQLException: Invalid column name
    If I use the following, then I do not get any error in retrieving data from the resultset.
    rset.getString(1);
    Any cause for this scenario?
    Thanks,
    TA

    Yes of course. I just the posted code snippet. This code used to work in old web server environment. Now we have to modify the resultset line to make it work when using ojdc14.jar.

  • Oracle Invalid Column Name Error in JSP

    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;

    Hi
    Thanks for your reply, I should of looked at my code before I copied over. The field should of been "studentinfo.familyname" which I was calling, I have just been changing so much code in this to try and see what the problem is, I didnt fix this before I copied this over.... trust me, I have tried everything........ Hence when I correctly called the "concatination the login name and password to the query properly" as you pointed out, I got rid of the error, BUT now it returning NO DATA????? (the table is populated - I have checked this!!!!)
    The table I am trying to get information from sits under a schema called system. It has the following columns;
    STUDENTID NUMBER 8
    FAMILYNAME VARHCAR 60
    GIVENNAME VARCHAR 60
    USERNAME VARCHAR 9
    PASSWORD VHARCHAR 60
    The database is called globaldb. My computer is called Midas2
    Whats more, the query works in Oracle sql*plus!!! Returning the relevent data!!!
    Actually here is the code for the JSP, with all the changes and none of the mistakes of my previous post...........,
    Pleaes help!!!
    <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 sqlQuery;
    sqlQuery = ("SELECT studentinfo.familyname FROM STUDENTINFO WHERE studentinfo.username='" + login + "' AND studentinfo.password='" + pswd + "'"); %>
    <% try { // execute the query
    Statement stmt = connection.createStatement();
    ResultSet rst;
    rst = stmt.executeQuery(sqlQuery);
    // Fetch the query result, and dispaly them in a table
    while (rst.next()) {
    %>
    <tr>
    <td> <%= rst.getString("studentinfo.familyname") %> </td>
    </tr>
    <%
    stmt.close();
    connection.close();
    } catch(Exception e) {
         out.println("Cannot fetch data from database!"+e);
    %>
    </body></html>

  • Strange error "Invalid column name 'not applicable'

    When I am trying this piece of code on Solaris 10 having sybase ASE 12.5 installed :
    ResultSet rs = stmt.executeQuery("sp_helpdb master");
    while(rs.next()){
    System.out.println(rs.getString(1));
    I am getting the following error:
    Invalid column name 'not applicable'
    This query returns multiple result sets.
    I am able to print all values in the first result set only.
    Its failing in rs.next();
    I am using jConnect 5.2 driver.
    The same query is executing fine on Solaris 8 having ASE 12.0 installed.
    If i use :
    ResultSet rs = stmt.executeQuery("sp_helpdb master");
    then there is no problem in Solaris 10
    Plz help me.
    Its urgent

    You need to use execute() not executeQuery() in the scenario below and use the multi-result set logic
    If you are using jConnect, see the samples for an example.

  • Invalid column name (with ojdbc)

    hi,
    I created a resultSet by executing query with more then one table in it. (left join)
    and now i want to getObject. so I execute resultSet.getObject("tablename.columnName")
    and I get this error "invalid column name".
    when i'm doing the same thing with MySQL it works fine.
    I don't want to do aliases for all the columns because there are too much of those.
    please help.
    thanks,
    asaf.

    that's not standard JDBC. You must use either the plain column name,
    or the column number. In cases where there are multiple columns with
    the same name you must use the column number for all but the first
    column with the same name.
    Joe Weinstein

Maybe you are looking for

  • I'm no longer able to manually arrange my albums

    Recently I have "lost" the ability to manually arrange my photo albums in the left-hand list. PReviously, I could grab an album, then drag it to the spot I wanted. iPhoto would idicate whether I was about to drop the album onto another by highlightin

  • Round up in condition type

    Hi everyone, I am able to round up in condition type for second digit.  but I want to know how we can round up for first digit.

  • Lotus Notes Tabbed tables do not display correctly

    When viewing a Lotus Note tabbed table in the Bridge, the initial display is correct (showing the first tab).  The other tabs show up as links.  When you click on one of the links a browser page opens but gives you a page not found error.  Thoughts?

  • Session EJB and JNDI

    I am encountering this problem while deploying my stateless session bean on WLS 6.x. My JNDI Tree shows two entries for the bean that i deploy. This does not happens when i deploy a stateful or entity bean on the server. The first entry in JNDI is of

  • FR Studio: Type mismatch error

    What could be the cause of an type mismatch error, when trying to open certain reports in FR Studio after it was exported from 9.3 and imported into 11.1.2.1 (patch 600)? These reports are running fine in Workspace as a PDF doc, but we are unable to