Home > Archive > PostgreSQL JDBC > July 2005 > a question, please help me.









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author a question, please help me.
wu xiao

2005-07-20, 11:23 am

Dear Sir or Madam,
I am in trouble when I try to connect postgresql 8.03 to JBuilder9 with
JDBC3 8.1. When I use no-parameter sql, my project runs well. For example,

Connection db = DriverManager. getConnection(url,us
er,pwd);
Statement st = db.createStatement();
ResultSet rs = st.executeQuery("select * from operator");
while(rs.next()) {
System.out.println("ID: "+rs.getString(1));
}
rs.close();
st.close();

The results are:
ID: 100
ID: 101
....

But when I try to use parameter sql, my project has sqlexceptions, for
example:

Connection db = DriverManager. getConnection(url,us
er,pwd);
PreparedStatement ps = db.prepareStatement("select * from operator where
ID=?");
ps.setString(1,100);
ResultSet rs = ps.executeQuery();
if(rs!=null) {
while(rs.next()) {
System.out.println("ID: "+rs.getString(1));
}
rs.close();
}
ps.close();

The sqlexception is:....column 'id' is not exist..... What's the reason
please? All of the tables are created in Windows XP.

Thank you for your any suggestion.

Sincerely,
Thomas Wu

____________________
____________________
____________________
_____
享用世界上最大的电子
邮件系统— MSN Hotmail。 http://www.hotmail.com


---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Dave Cramer

2005-07-20, 11:23 am

What does the table definition look like ?

in the first example you don't get the result by name so it could be
any column.

Dave
On 20-Jul-05, at 3:00 AM, wu xiao wrote:

> Dear Sir or Madam,
> I am in trouble when I try to connect postgresql 8.03 to
> JBuilder9 with JDBC3 8.1. When I use no-parameter sql, my project
> runs well. For example,
>
> Connection db = DriverManager. getConnection(url,us
er,pwd);
> Statement st = db.createStatement();
> ResultSet rs = st.executeQuery("select * from operator");
> while(rs.next()) {
> System.out.println("ID: "+rs.getString(1));
> }
> rs.close();
> st.close();
>
> The results are:
> ID: 100
> ID: 101
> ...
>
> But when I try to use parameter sql, my project has sqlexceptions,
> for example:
>
> Connection db = DriverManager. getConnection(url,us
er,pwd);
> PreparedStatement ps = db.prepareStatement("select * from operator
> where ID=?");
> ps.setString(1,100);
> ResultSet rs = ps.executeQuery();
> if(rs!=null) {
> while(rs.next()) {
> System.out.println("ID: "+rs.getString(1)); }
> rs.close();
> }
> ps.close();
>
> The sqlexception is锛....column 'id' is not exist..... What's the
> reason please? All of the tables are created in Windows XP.
>
> Thank you for your any suggestion.
>
> Sincerely,
> Thomas Wu
>
> ____________________
____________________
____________________
_____
> 浜敤涓栫晫涓婃渶澶
х殑鐢靛_愰偖浠剁郴
粺鈥 MSN Hotmail銆 http://
> www.hotmail.com
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 6: explain analyze is your friend
>
>




Dave Cramer
davec@postgresintl.com
www.postgresintl.com
ICQ #14675561
jabber davecramer@jabber.org
ph (519 939 0336 )


---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Oliver Jowett

2005-07-20, 8:24 pm

wu xiao wrote:

> PreparedStatement ps = db.prepareStatement("select * from operator where
> ID=?");


> The sqlexception is:....column 'id' is not exist..... What's the reason
> please? All of the tables are created in Windows XP.


If you've created the table with a capitalized column name, you will
need to quote it in your SQL:

"select * from operator where \"ID\"=?"

Unquoted identifiers (column names, table names, etc) are forced to
lowercase by the server.

-O

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com