• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jdbc:odbc issue under JRun

 
Ryan Alexander
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.*, java.io.*, 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 (resultSet.next())<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
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh dear! Mea culpa for the formatting error, and thanks much Ajith!
-ryan
 
Bjarki Holm
Author
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic