Conexion a base de datos remota
Publicado por sergio (8 intervenciones) el 30/07/2017 22:45:08
Hola tengo u problema
quiero conectarme a una base de datos remota de mysql desde mi android y mes sale el siguiente error ahi paso el codigo
nO me reconoe el getConnection me lo subraya siempre, dsde ya estaria muy agradecido por la ayuda que me puedan brindar
quiero conectarme a una base de datos remota de mysql desde mi android y mes sale el siguiente error ahi paso el codigo
nO me reconoe el getConnection me lo subraya siempre, dsde ya estaria muy agradecido por la ayuda que me puedan brindar
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package com.aide.trainer.myapp;
import android.app.*;
import android.os.*;
import android.view.*;
import android.widget.*;
import android.database.sqlite.*;
import android.database.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
public class MainActivity extends Activity
{
*
Connection con = DriverManager.getConnection("jdbc:mysql://hostinger.com.ar","basede datos","clave");
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
// Set main.xml as user interface layout
setContentView(R.layout.inicio);
}
public void onYesButtonClick(View view)
{
// This Java code shows a toast
//String query = "select sqlite_version() AS sqlite_version";
String query = "select * from miagenda";
//SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase(":memory:", null);
Cursor cursor = db.rawQuery(query, null);
String sqliteVersion = "";
if (cursor.moveToNext())
{
sqliteVersion = cursor.getString(0);
}
Toast.makeText(this, sqliteVersion, Toast.LENGTH_LONG).show();
}
public void onNoButtonClick(View view)
{
//hola
Toast.makeText(this, "Wrong!" , Toast.LENGTH_LONG).show();
}
}
Valora esta pregunta
![Me gusta: Está pregunta es útil y esta clara Me gusta: Está pregunta es útil y esta clara](/img/img.png?11.51)
![NO me gusta: Está pregunta no esta clara o no es útil No me gusta: Está pregunta no esta clara o no es útil](/img/img.png?11.51)
0