Bug #51618 error connecting: java.sql.SQLException: Column Index out of range, 0 < 1

Submitted: 1 Mar 2010 18:25 Modified: 9 Mar 2010 6:55
Reporter: Greg Beis Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:mysql-connector-java-5.1.12 OS:Windows (XP)
Assigned to: CPU Architecture:Any

[1 Mar 2010 18:25] Greg Beis
Description:
Hello,

Please help me solve the problem I'm facing. I get the error shown below, when I try to retrieve the stored "itemID" values from my MySQL database via a typical "resultSet.getString(i);" call: 

error connecting: java.sql.SQLException: Column Index out of range, 0 < 1.
error connecting: java.sql.SQLException: Column Index out of range, 0 < 1.

My table structure is the following:
CREATE TABLE `catalog` (
  `itemID` varchar(8) NOT NULL,
  `item` varchar(255) NOT NULL,
  `price` double default NULL,
  `descr` varchar(255) NOT NULL,
  PRIMARY KEY  (`itemID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

I use a simple "SELECT itemID FROM catalog ORDER BY itemID" query.

URL: jdbc:mysql://localhost:3306/eshopDB
Driver: com.mysql.jdbc.Driver
 
My servlet code runs under Eclipse 3.3.2 with Apache/Tomcat 6.0.24 and MySQL V5.0. I use JDK1.6.0_06. I keep my mysql-connector-java-5.1.12-bin.jar under $CATALINA_HOME/lib ($CATALINA_HOME = C:\apache-tomcat-6.0.24\lib) and the MySQL JDBC driver is up and running during the test.

If you need more symptoms, please let me know.
Thank you in advance,
Greg

How to repeat:
Problem is reproducible each time I step across the itemID row and retrieve the data in each cell via a resultSet.getString(i) call.
[3 Mar 2010 17:18] Tonci Grgin
Hi Greg and thanks for your report.

It seems you have troubles connecting. Did you passed username and password (jdbc:mysql://opensol:3306/test?user=root&password=***)?

If you do and you confirmed driver connected to server, can you please attach small but complete stand-alone test case exhibiting this error?
[9 Mar 2010 6:03] Greg Beis
Hello Tonci,

I managed to solve the problem by switching from MySQL 5.0 to MySQL 5.1 and by placing the mysq-connector-java5.1.12 under WEB-INF/lib/. 

Thank you for the support.

Regards,
Greg
[9 Mar 2010 6:55] Tonci Grgin
Greg, glad things work now.

If you can just determine which of the two changes caused code to work it might be helpful for others.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.050 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.