On Mon, Dec 08, 2003 at 09:38:26AM -0800, Prabu Subroto wrote:
Dear my friends...
Anybody would be so nice to tell me where the problem of script. I got this error message each time my code compiled: " patrixlinux@patrix:~/arsip/My/comadmin> javac utama.java utama.java:31: cannot resolve symbol symbol : method Int (java.lang.String) location: interface java.sql.ResultSet sCustomer = rs.Int("customerid");
^ 1 error patrixlinux@patrix:~/arsip/My/comadmin> "
Here is my code under below: ========= import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.sql.*;
public class utama { public static void main(String[] args){ System.out.println("Here is customer menu\n"); try {
Class.forName("com.mysql.jdbc.Driver").newInstance(); Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/amt?user=root&password=pandawa5"); System.out.println("Connection established\n"); // Do something with the Connection // assume conn is an already created JDBC connection Statement stmt = null; ResultSet rs = null; try { stmt = conn.createStatement(); rs = stmt.executeQuery("SELECT customerid FROM customer");
// or alternatively, if you don't know ahead of time that // the query will be a SELECT...
if (stmt.execute("SELECT customerid FROM customer")) { rs = stmt.getResultSet(); int sCustomer; // Now do something with the ResultSet .... while(rs.next()) // for each row of data { sCustomer = rs.Int("customerid");
This last line should read: sCustomer = rs.getInt("customerid"); Victor