zaheer Posted February 22, 2009 Share Posted February 22, 2009 Hi,I'm trying to develop a JDBC program to interact with an SQL Server running PostGres. I'm curious as to whether the following will work:String query = "SELECT CARNAME FROM CAR WHERE " + "CARYEAR=this.year";ResultSet rs= stmt.executeQuery(query);In the above within the query I used "this.year" which is a variable stored within the JDBC java program. Will this work??? Link to comment Share on other sites More sharing options...
Synook Posted February 23, 2009 Share Posted February 23, 2009 You have to concatenate the year property onto the string, or else it will pass this.year literally to ProgreSQL and that will try to find the `year` column in the `this` table. String query = "SELECT CARNAME FROM CAR WHERE " +"CARYEAR=" + this.year; Link to comment Share on other sites More sharing options...
zaheer Posted February 23, 2009 Author Share Posted February 23, 2009 thanx. it works. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.