This code how to apply ?

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class DB {

private static final String url = “jdbc:mysql://localhost/android”;
private static final String user = “root”;
private static final String password = “MySql Password”;

public static void main(String args[]) {

try {
Class.forName(“com.mysql.jdbc.Driver”);
Connection con = DriverManager.getConnection(url, user, password);
System.out.println(“Success”);
Statement st = con.createStatement();
ResultSet rs = st.executeQuery(“select * from User”);
while(rs.next()) {
System.out.println(“Id ” + rs.getInt(1));
System.out.println(“Data ” + rs.getString(2));
}

} catch (Exception e) {
e.printStackTrace();
}
}
}

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to