Results 1 to 3 of 3
- 12-04-2008, 03:07 PM #1
Member
- Join Date
- Nov 2008
- Posts
- 4
- Rep Power
- 0
Help!! how to turn query result to string
I have this code
while (rs.next()) {
String temp = rs.getString("localizacion_hora");
String [] temp2 = temp.split("\\-");
sql2 = "SELECT Asignaturas.nombre FROM Asignaturas , Horario WHERE Horario.codigo_asignatura = Asignaturas.codigo_asignatura AND Horario.localizacion_hora = '"+temp+"'";
rs2 = stmt.executeQuery(sql2);
model.insertRow(model.getRowCount(),
new Object[]{rs.getString("codigo_asignatura"), rs.getString("seccion"),
temp2[0], temp2[3], temp2[1], temp2[2], rs.getString("codigo_profesor")});
}
In red is a query that returns one value, a class name, how can i store that in a string ??
I tried this:
String temp = rs.getString("Asignaturas.nombre");
but didnt work =S
someone told me i should call resultset's next, but i tried that too and it didn't work, maybe im not doing it right (im obviously not doing it right =P)
Any help would be greatly appreciated!
- 12-04-2008, 07:11 PM #2
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 8
You need to use a new statement object (not the same one as for the first query) to set off the second query (and I assume you mean rs2.getString, rather than rs.getString). And yes an rs.next or rs.first is needed.
Last edited by masijade; 12-04-2008 at 07:13 PM.
- 12-11-2008, 11:42 AM #3
Member
- Join Date
- Dec 2008
- Posts
- 3
- Rep Power
- 0
Stefany, not sure if you have got the solution if not then apart from what masijade mentioned could you modify
String temp = rs.getString("Asignaturas.nombre");
to
String temp = rs.getString("nombre");
Possible error there is invalid column name. You can keep alias in the query statement but not in the rs.getString() method.
Similar Threads
-
Java Popup Window & Url Query String Value
By Rivelyn in forum New To JavaReplies: 4Last Post: 01-20-2011, 05:03 AM -
How to pass mysql string through a url parameter to a detail page query
By kwesiaryee in forum New To JavaReplies: 1Last Post: 08-22-2008, 06:28 PM -
Raising alerts based on query result across the network
By srinivasan.sr in forum NetworkingReplies: 2Last Post: 07-22-2008, 06:47 AM -
[SOLVED] General string problem in my database query.....?
By prabhurangan in forum New To JavaReplies: 7Last Post: 06-25-2008, 08:55 AM -
Export query result, procces is to slow
By Daniel in forum Enterprise JavaBeans (EJB)Replies: 2Last Post: 06-28-2007, 06:35 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks