|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
Counting records in a database?
this is my current code:
Unfortunately it is not scrolling through all of the records in the database. It is stuck on the first record. Any clues??? Any alternative ways to do this?? ____________________________________________________ <%@ page import = "java.sql.*" %> </head> <body bgcolor="#FFFFFF" text="#000000"> <% Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con = DriverManager.getConnection("jdbc dbc:login");Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY); ResultSet rs = stmt.executeQuery("SELECT * FROM People"); String user_id = request.getParameter("userID"); String pass_word = request.getParameter("pwd"); while( rs.next() ) { String email = rs.getString("Email"); if (user_id.equalsIgnoreCase(email)) { pageContext.forward("form.jsp"); session.setAttribute("LoggedIn", "true"); } else { pageContext.forward("errorpage.jsp"); } } con.close(); %> |
|
#2
|
||||
|
||||
|
You can try something like:
ResultSet rs = stmt.executeQuery("SELECT * FROM table"); while (rs.next()) { for(int col=1; col<=rs.getMetaData().getColumnCount();col++) System.out.print(rs.getString(col)+", "); System.out.println(); }
__________________
My blog about OpenSource Databases PDF tutorials about OSS databases, DBMonster ... Please contribute to Open Source Development, fill bug reports!!! Developer Shed eSupport Commented my.ini/my.cnf (PLEASE ADD YOUR OWN CONFIG TRICK) An introduction to database normalization Natural or Surrogate key Custom ordering for your results Correlated and uncorrelated subqueries Don't turn your outer joins into inner joins |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Java Help > Counting records in a database? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|