3

For the last 6-7 hours I've been searching/googling/experimenting for a solution to this but no results so far.

I have an SQL string(below) which works PERFECTLY in PHPMYADMIN but doesn't work within my java execution. When attempting to execute the query I get "Column rid Not Found."

SQLException:

java.sql.SQLException: Column 'rid' not found.
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1078)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:989)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:975)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:920)
at com.mysql.jdbc.ResultSetImpl.findColumn(ResultSetImpl.java:1167)
at com.mysql.jdbc.ResultSetImpl.getInt(ResultSetImpl.java:2851)
at net.matthewauld.racetrack.server.WrSQL.getJSONClassSpecificRiders(WrSQL.java:41)
at net.matthewauld.racetrack.server.ClientListener.parseCommand(ClientListener.java:110)
at net.matthewauld.racetrack.server.ClientListener.run(ClientListener.java:42)

--

SELECT * FROM `riders` WHERE EXISTS(SELECT * FROM `ridersclasses` WHERE ridersclasses.rid = riders.id AND `cid` = '6') ORDER BY `first_name` ASC

Here is my java code to execute the SQL Query.

url = "jdbc:mysql://127.0.0.1:3306/racetrack2013?allowMultiQueries=true";
con = DriverManager.getConnection(url, user, password);
st = con.createStatement();
rs = st.executeQuery(query);

Below I will post the structure of the two tables and some data examples:

RidersClasses

+---------------------------------------------------+
|                   ridersclasses                   |
+---------------------------------------------------+
|  ID  |  RID  |  CID  |  BIKENUMBER  |  BIKEMODEL  |
+---------------------------------------------------+

Riders

+----------------------------------------------------------------------------------+
|                                         Riders                                   |
+----------------------------------------------------------------------------------+
|  ID  |  first_name  | last_name  |  address  |  city_id  |  h_phone  |  c_phone  |
+----------------------------------------------------------------------------------+
Matthew Auld
  • 388
  • 1
  • 3
  • 18

1 Answers1

6

The problem is simple : there's no rid column in riders table.

As its shown in the strack trace the problem starts at getInt

So instead of rs.getInt("rid") use rs.getInt("id")

Stephan
  • 8,000
  • 3
  • 36
  • 42