File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

sqlException column not found

 
numan ahmad
Ranch Hand
Posts: 49
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i want to make connection with my database just want to print all records, for this purpose i wrote a query like that



String driver="sun.jdbc.odbc.JdbcOdbcDriver";
Class.forName(driver);

String db="jdbcdbc:database1";
con=DriverManager.getConnection(db);
st=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql="select * from customer,product,inventry,accounts";
rs=st.executeQuery(sql);


it give me sql exception error..i want to know that is it rite way to write query if not then what should be rite?
i search a lot on Google but did not succeed please help me and thanks in advance ..
 
Vijay Tidake
Ranch Hand
Posts: 146
Hibernate Java Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

will you please provide some stackstrace of the sqlException.

Thanks
 
numan ahmad
Ranch Hand
Posts: 49
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
SQLException: column not found

at jdbc.odbc.jdbcodbcResultSet.find column(jdbcodbcResultSet.java:180)

at jdbc.odbc.jdbcodbcResultSet.getString(jdbcodbcResultSet.java:411)
 
Vijay Tidake
Ranch Hand
Posts: 146
Hibernate Java Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I this the error is in query.Please check it.

select * from customer,product,inventry,accounts

Thanks
 
Paul Clapham
Sheriff
Pie
Posts: 20187
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, that was numan's question... "What is wrong with this query?"

My question is, what is the query supposed to do? To me it looks like a four-way Cartesian product of four unrelated files. That wouldn't be a good idea so there isn't much point in trying to make it work.
 
Vijay Tidake
Ranch Hand
Posts: 146
Hibernate Java Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry Paul..
I didn't get you.
 
Paul Clapham
Sheriff
Pie
Posts: 20187
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's just that since numan said
i want to know that is it rite way to write query if not then what should be rite?

I didn't think that just telling him/her to check the query was very helpful. He/she already knew there was a problem with it, and wanted to know what the problem was.

(However I don't know what the problem is either, so perhaps my answer didn't help much. And then numan is using MS Access, which is well-known for providing useless error messages like that one...)
 
Vijay Tidake
Ranch Hand
Posts: 146
Hibernate Java Tomcat Server
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok..got it
thanks for suggestion
 
numan ahmad
Ranch Hand
Posts: 49
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry i did not get you paul would you explain it more ?
 
numan ahmad
Ranch Hand
Posts: 49
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i want to retrieve data from multiple tables...the query that i wrote is it rite or not if not then please tell me the correct way to retrieve data ?
 
Paul Clapham
Sheriff
Pie
Posts: 20187
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know. Normally to select data from several tables you would do some kind of a join. If you really want to do the four-way cartesian product then you might have to do something different.

For example if two tables had a column with the same name, you might not be able to use "Select *" in that case. You might have to specify the names of the columns you want, complete with prefix to indicate which table they were coming from.

However I still advise you to start with a reasonable query. Trying to learn SQL from bad ideas is not a good approach.
 
numan ahmad
Ranch Hand
Posts: 49
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hmmmmm ok thanks a lot....
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic