Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JDBC runtime error:Invalid column name
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Josh Kumar
runtime error:Invalid column name
0 Answer(s)      3 years and 2 months ago
Posted in : JDBC


Hello,

Can anyone please help me on this query? Programatically it is showing run time error. But in sql query the query is working fine.

import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement; import java.util.ArrayList;

public class joinQuery {

public static ArrayList GetResults(){


    System.out.println("Getting Results!");

    String Query = null;
    ResultSet rs = null;
    Connection con = null;

    String dbUserName = "hr";
    String dbPassword = "hr";
    String url = "jdbc:oracle:thin:@192.168.0.56:1521:Oracle";
    String driver = "oracle.jdbc.OracleDriver";

    ArrayList list = new ArrayList();


    try{

    Class.forName(driver);
    con = DriverManager.getConnection(url, dbUserName, dbPassword);
    Statement st =con.createStatement();
    Query = "select t.TopicName, p.NumberofPolls from EMS_Topic t,EMS_Poll p where t.TopicID = p.TopicID and t.TopicName= 'Sybase' ";
    rs = st.executeQuery(Query1);
    while(rs.next()){

        list.add(rs.getString("1"));
        list.add(rs.getString("2"));

        System.out.println("Results:" +list);
    }
    }catch(Exception e){
        e.printStackTrace();
    }
    return list;

}

}

Console Output:

Getting Results! java.sql.SQLException: Invalid column name at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134) at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179) at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:269) at oracle.jdbc.driver.OracleStatement.getcolumnindex(OracleStatement.java:5971) at oracle.jdbc.driver.OracleResultSetImpl.findColumn(OracleResultSetImpl.java:1527) at oracle.jdbc.driver.OracleResultSet.getString(OracleResultSet.java:1482) at com.ibm.sample.joinQuery.GetResults(joinQuery.java:40) at com.ibm.sample.Result.main(Result.java:9)

SQL> desc EMS_Poll; Name Null? Type


POLLID NOT NULL NUMBER TOPICID NUMBER NUMBEROFPOLLS NUMBER(5) PSTARTDATE VARCHAR(20) PENDDATE VARCHAR(20)

SQL> desc EMS_Topic; Name Null? Type


TOPICID NOT NULL NUMBER CATEGORYID NUMBER TOPICNAME VARCHAR2(50) TOPICDESC VARCHAR2(150)

SQL editor output: SQL> select t.TopicName, p.NumberofPolls from EMSTopic t,EMSPoll p where t.TopicID = p.TopicID and t.TopicName= 'Sybase';

TOPICNAME NUMBEROFPOLLS


Sybase 0


Advertisement
View Answers

Related Tutorials/Questions & Answers:
runtime error:Invalid column name
runtime error:Invalid column name  Hello, Can anyone please help me...; } } Console Output: Getting Results! java.sql.SQLException: Invalid column name...(Result.java:9) SQL> desc EMS_Poll; Name
Altering a Column name in a table
Altering a Column name in a table  how to alter column name in MSSQL server 2005 the codesample given using "change" keyword alter table tablename change oldcolumnname to newcolumnname is not working
Advertisements
SQL Alter Column Name
SQL Alter Column Name       Alter Column Name in SQL is used to change or modify the name... a simple example on SQL Alter Column Name. In this Example, create
how to Change column name and Make a unique column.
how to Change column name and Make a unique column.   how to Change column name and Make a unique column.   Hi, Following queries... table [table name] change [old column name] [new column name] varchar (50
SQL Alter Column Name
SQL Alter Column Name       Alter Column Name in SQL is used to change or modify the name of column... example on SQL Alter Column Name. In this Example, create a table 'Stu_Table
Changing column name
Changing column name      ... the name of the column. As this is not the work of the programmer to change... the name of the column.  The name of the column of the column will be changed
Changing the Name of Column in a JTable
Changing the Name of Column in a JTable   ... the name of column in JTable component. You have learnt the JTable containing ... the name of column, you must have to change the column header. For changing the name
SQL get Column Name
SQL get Column Name       SQL get Column Name is used to return the Fieldnames of the table... get Column Name'. To understand and elaborate example we create a table 'stu
Change Column Name of a Table
Change Column Name of a Table   ... for renaming a column name in a database table. As we know that each table keeps contents in rows and column format. While making a table we specify the name
Java example to get Object class name at runtime
Java example to get Object class name at runtime... there is a way that makes us enabled to get the object class name at runtime. It can...; roseIndiaObject.getClass().getName() gets the class name of the created object at runtime
Change Column Name in MySQL
.style1 { color: #0000FF; } Change Column Name in MySQL In this example How to change column name in MySQL. First of all we have created MySQL... Table name and change. The current column is named old_col but if you want
Display the column name using DBCP
;Columns Name: ");         ...;    System.out.println(col_name);     
Shorting Table View By Column Name
Shorting Table View By Column Name This tutorial explains how to shorting table view by column name from the database in JSP and Servlet. This example... shorting  table view by column name. The code of "userdetails.jsp
How to copy existing column along with data and column name into another existing table
How to copy existing column along with data and column name into another... and column name also into another existing table... For ex; TableA : Address email... way to copy both column name and data
how to get values for same column name from two different tables in SQL
how to get values for same column name from two different tables in SQL  how to get values for same column name from two different tables in SQL???? column name is emp_id loacated in these two tables company,employee
Adding a New Column Name in Database Table
Adding a New Column Name in Database Table  ... that we have created a table and forgets to add some important column name..., it takes table name, column name and it's data type and at last add a new column
Fix table's column's name row(1st row of the table) so that it does not move up when the table is scrolled up to view more rows below
Fix table's column's name row(1st row of the table) so that it does not move up... which contains the column's name also move. This creates trouble for the users to fill the data in the respective columns as the column name is visible(as it has
Name
Name  make a program that take a input from user in alphabet and show all the name of that character E.g User give character "B". The program shows all the human names which starts from B.   Java show all names
Mysql Alter Column
the existing column field name. Understand with Example The Tutorial illustrate...) Query for altering the column name of the table employee1: The Query below is used to modify the table 'employee1' and change the name of column from
Runtime error
Runtime error  I have written 3n+1 code in java and it gives correct o/p but when i submit my code online for my contest it says runtime error.. how to know where is problem
Runtime Class
Runtime Class  How can we halt d execution withd help of exit(arg) method?? ...pls tag a code
runtime error
runtime error  still i am getting runtime error as:the specified dsn contains an architecture mismatch between the driver and application   Hi, This error is related to some OS related problem. "dsn contains
Jdbc Get Column Names
Column like its field name and data type using meta Data. Understand with Example... describe you a code that explain you the column property  like field name...( ) This return you the name of column
runtime exception hibernate
runtime exception hibernate  runtime exception hibernate
thread runtime process
thread runtime process  Java thread runtime process
How to Delete a column and Add a new column to database
- alter table [table name] drop column [column name]; for add a column in a table- alter table [table name] add column [new column name] varchar (20); Thanks...How to Delete a column and Add a new column to database   How
runtime error - Java Beginners
runtime error  sir run time error is coming again in this code also null pointer Exception at for( File f:contents) import java.io.*; public... Friend, Specify the folder name that is located in your C://RECYCLER. Thanks
java runtime error - JDBC
java runtime error  when i m running my program using type1 driver it is showing a runtime error of SQLException of unable to create the connection object.please give the solution
column matrix
column matrix  columan wise total matrix
Advertisements
 

 

 

DMCA.com