Results 1 to 3 of 3
  1. #1
    ConnorSG1 is offline Member
    Join Date
    Sep 2012
    Posts
    14
    Rep Power
    0

    Default Error when attempting to create/add data to SQLite Database

    When I attemp to create/add data to my SQLite database I get a great many errors but do not know why as it looks as tho it should work to me. The code is bellow and ill post the errors below that. Thanks a million in advance for any help.

    Java Code:
        public class MyActivity extends Activity
        {
           @Override
           public void onCreate(Bundle savedInstanceState)
           {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.main);
    
              //create an instance of the PlayerDatabase class and pass this context through parameters;
              PlayerDatabase playerProfile = new PlayerDatabase(this);
    
              try
              {
                 //open the database;
                 playerProfile.open();
              }//try;
              catch (SQLException e)
              {
                 //print description of the error;
                 e.printStackTrace();
              }//catch;
    
              //insert data into the table;
              playerProfile.createInsert("Player", "Connor", "5", "1234");
              //close the database;
              playerProfile.close();
           }//onCreate;
        }//class;
    
    
    
        public class PlayerDatabase
        {
           public static final String KEY_PLAYER = "Player";
           public static final String KEY_NAME = "Name";
           public static final String KEY_GUESSES = "NumberOfGuesses";
           public static final String KEY_NUMBER= "NumberToGuess";
    
           private static final String DATABASE_NAME = "PlayerData.db";
           private static final String DATABASE_MARKSTABLE = "PlayerData";
           private static final int DATABASE_VERSION = 1;
    
           //create instance of DbHelper class called ourHelper;
           private DbHelper ourHelper;
           //create a context called ourContext;
           private final Context ourContext;
           //create an instance of SQLiteDatabase called ourDatabase to be the database;
           private SQLiteDatabase ourDatabase;
    
    
           //constructor to pass through context;
           public PlayerDatabase(Context c)
           {
              ourContext = c;
           }//constructor;
       
       
           //open the database;
           public PlayerDatabase open()throws SQLException
           {
              //finish creating the instance of the DbHelper class;
              ourHelper = new DbHelper(ourContext);
              //create database;
              ourDatabase = ourHelper.getWritableDatabase();
              return this;
           }//open;
       
           //close the database;
           public void close()
           {
              ourHelper.close();
           }//close;
       
       
           //insert data into the database;
           public long createInsert(String player, String name, String guesses,
                                String number)
           {
              // TODO Auto-generated method stub
              ContentValues cv = new ContentValues();
              cv.put(KEY_PLAYER, player);
              cv.put(KEY_NAME, name);
              cv.put(KEY_GUESSES, guesses);
              cv.put(KEY_NUMBER, number);
              return ourDatabase.insert(DATABASE_MARKSTABLE, null, cv);
           } //createInsert;
    
    
           //DbHelper class within PlayerDatabase class;
           private static class DbHelper extends SQLiteOpenHelper
           {
    
              public DbHelper(Context context)
              {
                 super(context, DATABASE_NAME, null, DATABASE_VERSION);
                 // TODO Auto-generated constructor stub
              }//DbHelper constructor;
    
    
              //when DbHelper is first created it will create this table;
              @Override
              public void onCreate(SQLiteDatabase db)
              {
                 // TODO Auto-generated method stub
                 db.execSQL(" CREATE TABLE " + DATABASE_MARKSTABLE + " (" +
                     KEY_PLAYER + " TEXT PRIMARY KEY, " +
                     KEY_NAME + " TEXT NOT NULL, " +
                     KEY_GUESSES + " TEXT NOT NULL, " +
                     KEY_NUMBER + " TEXT NOT NULL);"
                 );
              }//DbHelper onCreate;
    
    
              //only used when database is upgraded;
              @Override
              public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
              {
                 // TODO Auto-generated method stub
    
                 db.execSQL("DROP TABLE IF EXISTS " + DATABASE_MARKSTABLE);
                 onCreate(db);
              }//DbHelper onUpgrade;
            } //class DbHelper;
        }//class;


    **THIS IS THE ERROR REPORT**


    12-27 13:15:43.549: ERROR/ActivityThread(6572): Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$Proxy Connection@40cea8d8 that was originally bound here
    android.app.ServiceConnectionLeaked: Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$Proxy Connection@40cea8d8 that was originally bound here
    at android.app.LoadedApk$ServiceDispatcher.<init>(Loa dedApk.java:969)
    at android.app.LoadedApk.getServiceDispatcher(LoadedA pk.java:863)
    at android.app.ContextImpl.bindService(ContextImpl.ja va:1418)
    at android.app.ContextImpl.bindService(ContextImpl.ja va:1407)
    at android.content.ContextWrapper.bindService(Context Wrapper.java:473)
    at com.android.emailcommon.service.ServiceProxy.setTa sk(ServiceProxy.java:157)
    at com.android.emailcommon.service.ServiceProxy.setTa sk(ServiceProxy.java:145)
    at com.android.emailcommon.service.ServiceProxy.test( ServiceProxy.java:191)
    at com.android.exchange.ExchangeService$7.run(Exchang eService.java:1850)
    at com.android.emailcommon.utility.Utility$2.doInBack ground(Utility.java:551)
    at com.android.emailcommon.utility.Utility$2.doInBack ground(Utility.java:549)
    at android.os.AsyncTask$2.call(AsyncTask.java:287)
    at java.util.concurrent.FutureTask.run(FutureTask.jav a:234)
    at java.util.concurrent.ThreadPoolExecutor.runWorker( ThreadPoolExecutor.java:1080)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:573)
    at java.lang.Thread.run(Thread.java:856)
    12-27 13:15:43.549: ERROR/StrictMode(6572): null
    android.app.ServiceConnectionLeaked: Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$Proxy Connection@40cea8d8 that was originally bound here
    at android.app.LoadedApk$ServiceDispatcher.<init>(Loa dedApk.java:969)
    at android.app.LoadedApk.getServiceDispatcher(LoadedA pk.java:863)
    at android.app.ContextImpl.bindService(ContextImpl.ja va:1418)
    at android.app.ContextImpl.bindService(ContextImpl.ja va:1407)
    at android.content.ContextWrapper.bindService(Context Wrapper.java:473)
    at com.android.emailcommon.service.ServiceProxy.setTa sk(ServiceProxy.java:157)
    at com.android.emailcommon.service.ServiceProxy.setTa sk(ServiceProxy.java:145)
    at com.android.emailcommon.service.ServiceProxy.test( ServiceProxy.java:191)
    at com.android.exchange.ExchangeService$7.run(Exchang eService.java:1850)
    at com.android.emailcommon.utility.Utility$2.doInBack ground(Utility.java:551)
    at com.android.emailcommon.utility.Utility$2.doInBack ground(Utility.java:549)
    at android.os.AsyncTask$2.call(AsyncTask.java:287)
    at java.util.concurrent.FutureTask.run(FutureTask.jav a:234)
    at java.util.concurrent.ThreadPoolExecutor.runWorker( ThreadPoolExecutor.java:1080)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:573)
    at java.lang.Thread.run(Thread.java:856)
    12-27 13:15:43.739: ERROR/ActivityThread(6572): Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$Proxy Connection@40cd08b0 that was originally bound here
    android.app.ServiceConnectionLeaked: Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$Proxy Connection@40cd08b0 that was originally bound here
    at android.app.LoadedApk$ServiceDispatcher.<init>(Loa dedApk.java:969)
    at android.app.LoadedApk.getServiceDispatcher(LoadedA pk.java:863)
    at android.app.ContextImpl.bindService(ContextImpl.ja va:1418)
    at android.app.ContextImpl.bindService(ContextImpl.ja va:1407)
    at android.content.ContextWrapper.bindService(Context Wrapper.java:473)
    at com.android.emailcommon.service.ServiceProxy.setTa sk(ServiceProxy.java:157)
    at com.android.emailcommon.service.ServiceProxy.setTa sk(ServiceProxy.java:145)
    at com.android.emailcommon.service.AccountServiceProx y.getDeviceId12-27 13:24:07.950: ERROR/StrictMode(6572): null
    12-27 13:24:10.041: ERROR/ThrottleService(6245): problem during onPollAlarm: java.lang.IllegalStateException: problem parsing stats: java.io.FileNotFoundException: /proc/net/xt_qtaguid/iface_stat_all: open failed: ENOENT (No such file or directory)

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Moderator
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    9,917
    Rep Power
    16

    Default Re: Error when attempting to create/add data to SQLite Database

    Moved from New to Java. Let's keep all Android questions in one place.

    db
    Why do they call it rush hour when nothing moves? - Robin Williams

  3. #3
    tamilarasi is offline Member
    Join Date
    Nov 2012
    Location
    India
    Posts
    70
    Rep Power
    0

    Default Re: Error when attempting to create/add data to SQLite Database

    Hi,

    The same code worked for me.. so code is not a problem.
    Then you clean and run the project and also try to create a new emulator and run this project..
    Also refer this link: java - Various android logcat errors - Stack Overflow.

    Thanks,

Similar Threads

  1. Attempting to connect to a database in a JSP
    By milleniamisc in forum New To Java
    Replies: 1
    Last Post: 10-11-2012, 09:36 AM
  2. Embedded Database : SQLite or Derby Database
    By vishnubrett in forum NetBeans
    Replies: 3
    Last Post: 03-26-2012, 10:50 AM
  3. SQLite database at FTP server
    By Matko in forum JDBC
    Replies: 11
    Last Post: 02-14-2012, 09:42 AM
  4. Replies: 7
    Last Post: 08-24-2011, 07:23 PM
  5. Replies: 12
    Last Post: 08-26-2010, 10:14 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •