• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

sqlException column not found

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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="jdbc:odbc: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 ..
 
Ranch Hand
Posts: 148
Hibernate Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

will you please provide some stackstrace of the sqlException.

Thanks
 
numan ahmad
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 148
Hibernate Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

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

select * from customer,product,inventry,accounts

Thanks
 
Sheriff
Posts: 28401
100
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 148
Hibernate Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry Paul..
I didn't get you.
 
Paul Clapham
Sheriff
Posts: 28401
100
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 148
Hibernate Tomcat Server Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok..got it
thanks for suggestion
 
numan ahmad
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry i did not get you paul would you explain it more ?
 
numan ahmad
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 28401
100
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hmmmmm ok thanks a lot....
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic