File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes jdbc:odbc issue under JRun Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "jdbc:odbc issue under JRun" Watch "jdbc:odbc issue under JRun" New topic

jdbc:odbc issue under JRun

Ryan Alexander

Joined: May 23, 2001
Posts: 8
I just wanted to post this here to see if someone else had run across this, or to help someone who is going to.
Here's what I'm doing on a .jsp page in JRun (windows 2000 install)
< %@ page import="javax.naming.*, javax.rmi.PortableRemoteObject, java.sql.*, javax.sql.*,*, javax.servlet.*, javax.servlet.http.*" % >
< %<br /> Connection m_connection = null;<br /> Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();<br /> m_connection = DriverManager.getConnection("jdbc dbc:TestingCams;user=XXXXXXXXX;password=XXXXXXXXX");<br /> String query = "SELECT ID, NAME, TITLE, ADULT, FORMAT, CATEGORY, URL from TestCams";<br /> Statement statement = m_connection.createStatement();<br /> ResultSet resultSet = statement.executeQuery(query);<br /> String title = "Title";<br /> while (<br /> { %>
< %=resultSet.getString("ID")%>
< %=resultSet.getString("NAME")%>
< %=resultSet.getString("URL")%>
< %}%>

I know it's a bit hodge-podge, but here's the weird part. If instead of naming the colums in the SQL statement I use the 'SELECT * from' version, the resultSet won't let me access the columns by string (and this is the _really_ weird part) EXECEPT for the FIRST column...
strangest damned thing...
[Ajith inserted spaces after the < tag so that the code appears as text and not get interpreted by UBB as code! ]
[This message has been edited by Ajith Kallambella (edited June 12, 2001).]
Ryan Alexander

Joined: May 23, 2001
Posts: 8
Oh dear! Mea culpa for the formatting error, and thanks much Ajith!
Bjarki Holm
Ranch Hand

Joined: May 25, 2001
Posts: 65
Yes, this is strange. But it's always a better practise to explicitly name the columns you're selecting, so this could be easily avoided
Bjarki Holm
Author of Professional Java Data

Bjarki Holm
I agree. Here's the link:
subject: jdbc:odbc issue under JRun
It's not a secret anymore!