Hi,
I'm developing an APP for android which requires a database, i'm using mySQL, but haven't had any luck with it's connection, this is my code:
connection class:
public class MySQLConnect extends Activity{
public void onCreate(Bundle savedInstanceState) {
}
public static void connection(String[] args ) throws Exception{
Class.forName("com.mysql.jdbc.Driver");
Connection con=(Connection) DriverManager.getConnection("jdbc:mysql://localhost/prom.pt_test", "root", "root");
PreparedStatement statement = con.prepareStatement("SELECT * FROM users");
ResultSet result=statement.executeQuery();
while(result.next()){
System.out.println(result.getString(1) + "" + result.getString(2));
}
}
}
Android manifest:
<activity
android:name=".MySQLConnect"
>
startActivity:
Button testButton = (Button) findViewById(R.id.button1);
testButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(LoginScreen.this, MySQLConnect.class));
}
});
Am i doing anything wrong???
Any help would be appreciated.