當前位置: 首頁>>代碼示例>>Java>>正文


Java SQLException.printStackTrace方法代碼示例

本文整理匯總了Java中android.database.SQLException.printStackTrace方法的典型用法代碼示例。如果您正苦於以下問題:Java SQLException.printStackTrace方法的具體用法?Java SQLException.printStackTrace怎麽用?Java SQLException.printStackTrace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.database.SQLException的用法示例。


在下文中一共展示了SQLException.printStackTrace方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onClick

import android.database.SQLException; //導入方法依賴的package包/類
@Override
public void onClick(View view) {
    try {
        // save this group to database ....
        ArticlesDataSource mDbHelper = new ArticlesDataSource(getApplicationContext());
        mDbHelper.createDatabase();
        mDbHelper.open();
        long lastInsertedId = mDbHelper.saveGroup(groupName, listOfIdsLessons);
        if (lastInsertedId != -1) {
            //Toast.makeText(getApplicationContext(), R.string.group_has_been_saved, Toast.LENGTH_SHORT).show();
            // ... and go to activity to show it
            Intent intent = new Intent(getApplicationContext(), AllArticlesListViewActivity.class);
            intent.putExtra("group_id", lastInsertedId);
            intent.putExtra("group_name", groupName);
            intent.putExtra("status_what_show", ActivityArticlesStatusToShow.SHOW_ALL_GROUPS);
            startActivity(intent);
        } else {
            // throw exception
        }
    } catch (SQLException e) {
        e.printStackTrace();
    }
}
 
開發者ID:white-collar,項目名稱:mobile-grammar,代碼行數:24,代碼來源:AddReminderToGroupActivity.java

示例2: addAgentInfo

import android.database.SQLException; //導入方法依賴的package包/類
public boolean addAgentInfo(AgentInfo agentInfo) {
	try {

		if (getSQLiteDatabase() == null) {
			return false;
		}

		String sql = "replace into "
				+ UdeskDBHelper.UdeskAgentMsg
				+ "(AgentJid ,HeadUrl ,AgentNick )"
				+ " values (?,?,?)";

		getSQLiteDatabase().execSQL(
				sql,
				new Object[] { agentInfo.getAgentJid(),agentInfo.getHeadUrl(),agentInfo.getAgentNick()});
		return true;
	} catch (SQLException e) {
		e.printStackTrace();
		return false;
	}
}
 
開發者ID:lennyup,項目名稱:react-native-udesk,代碼行數:22,代碼來源:UdeskDBManager.java

示例3: insert_sqlite

import android.database.SQLException; //導入方法依賴的package包/類
private long insert_sqlite() {
    long start = System.currentTimeMillis();

    // 在一個事物裏麵運行
    _Database.beginTransaction();

    try {
        for (int i = 0; i < MAX; i++) {
            String sql = "insert into dog(name) values('哈士奇')";
            _Database.execSQL(sql);
        }
        _Database.setTransactionSuccessful();
    } catch (SQLException e) {
        e.printStackTrace();
    } finally {
        _Database.endTransaction();
    }

    long end = System.currentTimeMillis();

    return end - start;
}
 
開發者ID:linheimx,項目名稱:ObjectBoxTest,代碼行數:23,代碼來源:PerformanceActivity.java

示例4: refreshDisplay

import android.database.SQLException; //導入方法依賴的package包/類
private void refreshDisplay(Context context, int type) {
    try {
        db.open();
        if (type != 0) {
            changes = db.getAllItms(type);
        } else {
            changes = db.getAllItms();
        }
    } catch (SQLException e) {
        FirebaseCrash.report(e);
        e.printStackTrace();
    }
    db.close();

    if (changes != null) {
        listAdapter = new changeAdapter(context, changes);
        listView.setAdapter(listAdapter);
    }
}
 
開發者ID:pooyafaroka,項目名稱:PlusGram,代碼行數:20,代碼來源:userChanges.java

示例5: BaseDAO

import android.database.SQLException; //導入方法依賴的package包/類
public BaseDAO(final Context context) {
    this.context = context;
    dbHelper = DataBaseHelper.getInstance();
    try {
        open();
    } catch (SQLException e) {
        Log.e(TAG, "SQLException on openning database " + e.getMessage());
        e.printStackTrace();
    }
}
 
開發者ID:WorldBank-Transport,項目名稱:RoadLab-Pro,代碼行數:11,代碼來源:BaseDAO.java

示例6: getTabs

import android.database.SQLException; //導入方法依賴的package包/類
public ArrayList<HashMap<String, Integer>> getTabs() {
    ArrayList<HashMap<String, Integer>> hashMaps = new ArrayList<>();
    String query = "SELECT * FROM " + TABS_TABLE;
    Cursor cursor = getDatabase().rawQuery(query, null);
    if (cursor != null && cursor.getCount() > 0) {
        if (cursor.moveToFirst()) {
            do {
                HashMap<String, Integer> stringIntegerHashMap = new HashMap<>();
                stringIntegerHashMap.put(cursor.getString(cursor.getColumnIndex(TAB_NAME)), cursor.getInt(cursor.getColumnIndex(TAB_POSITION)));
                hashMaps.add(stringIntegerHashMap);
            } while (cursor.moveToNext());
        }
        cursor.close();
        return hashMaps;

    } else {
        String[] tabs = Common.getInstance().getResources().getStringArray(R.array.fragments_titles);

        for (int i = 0; i < tabs.length; i++) {
            ContentValues values = new ContentValues();
            values.put(TAB_NAME, tabs[i]);
            values.put(TAB_POSITION, i);
            try {
                getDatabase().insertOrThrow(TABS_TABLE, null, values);
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }

        return getTabs();
    }
}
 
開發者ID:reyanshmishra,項目名稱:Rey-MusicPlayer,代碼行數:33,代碼來源:DataBaseHelper.java

示例7: addMessageInfo

import android.database.SQLException; //導入方法依賴的package包/類
/**
 * db中增加一條消息的語句
 * 
 * @param msg
 */

public boolean addMessageInfo(MessageInfo msg) {
	try {

		if (getSQLiteDatabase() == null || msg == null) {
			return false;
		}

		String sql = "replace into "
				+ UdeskDBHelper.UdeskMessage
				+ "(MsgID ,Time ,MsgContent,MsgType,ReadFlag,SendFlag,PlayedFlag,"
				+ "Direction,LocalPath,Duration,AgentJid,created_at,updated_at,reply_user,reply_userurl)"
				+ " values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";

		getSQLiteDatabase().execSQL(
				sql,
				new Object[] { msg.getMsgId(), msg.getTime(),
						msg.getMsgContent(), msg.getMsgtype(),
						msg.getReadFlag(), msg.getSendFlag(),
						msg.getPlayflag(), msg.getDirection(),
						msg.getLocalPath(), msg.getDuration() ,
						msg.getmAgentJid(),msg.getCreatedTime(),
						msg.getUpdateTime(),msg.getReplyUser(),
						msg.getUser_avatar()
				});
		return true;
	} catch (SQLException e) {
		e.printStackTrace();
		return false;
	}
}
 
開發者ID:lennyup,項目名稱:react-native-udesk,代碼行數:37,代碼來源:UdeskDBManager.java

示例8: updateFolderItemsRank

import android.database.SQLException; //導入方法依賴的package包/類
@Thunk boolean updateFolderItemsRank(SQLiteDatabase db, boolean addRankColumn) {
    db.beginTransaction();
    try {
        if (addRankColumn) {
            // Insert new column for holding rank
            db.execSQL("ALTER TABLE favorites ADD COLUMN rank INTEGER NOT NULL DEFAULT 0;");
        }

        // Get a map for folder ID to folder width
        Cursor c = db.rawQuery("SELECT container, MAX(cellX) FROM favorites"
                + " WHERE container IN (SELECT _id FROM favorites WHERE itemType = ?)"
                + " GROUP BY container;",
                new String[] {Integer.toString(LauncherSettings.Favorites.ITEM_TYPE_FOLDER)});

        while (c.moveToNext()) {
            db.execSQL("UPDATE favorites SET rank=cellX+(cellY*?) WHERE "
                    + "container=? AND cellX IS NOT NULL AND cellY IS NOT NULL;",
                    new Object[] {c.getLong(1) + 1, c.getLong(0)});
        }

        c.close();
        db.setTransactionSuccessful();
    } catch (SQLException ex) {
        // Old version remains, which means we wipe old data
        ex.printStackTrace();
        return false;
    } finally {
        db.endTransaction();
    }
    return true;
}
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:32,代碼來源:LauncherProvider.java

示例9: addEQValues

import android.database.SQLException; //導入方法依賴的package包/類
/**
 * Saves a song's equalizer/audio effect settings to the database.
 */

public void addEQValues(int fiftyHertz,
                        int oneThirtyHertz,
                        int threeTwentyHertz,
                        int eightHundredHertz,
                        int twoKilohertz,
                        int fiveKilohertz,
                        int twelvePointFiveKilohertz,
                        int virtualizer,
                        int bassBoost,
                        int reverb,
                        int volume) {

    ContentValues values = new ContentValues();
    values.put(EQ_50_HZ, fiftyHertz);
    values.put(EQ_130_HZ, oneThirtyHertz);
    values.put(EQ_320_HZ, threeTwentyHertz);
    values.put(EQ_800_HZ, eightHundredHertz);
    values.put(EQ_2000_HZ, twoKilohertz);
    values.put(EQ_5000_HZ, fiveKilohertz);
    values.put(EQ_12500_HZ, twelvePointFiveKilohertz);
    values.put(VIRTUALIZER, virtualizer);
    values.put(BASS_BOOST, bassBoost);
    values.put(REVERB, reverb);
    values.put(VOLUME, volume);


    try {
        getDatabase().insertOrThrow(EQUALIZER_TABLE, null, values);
    } catch (SQLException e) {
        e.printStackTrace();
    }

}
 
開發者ID:reyanshmishra,項目名稱:Rey-MusicPlayer,代碼行數:38,代碼來源:DataBaseHelper.java

示例10: onCreate

import android.database.SQLException; //導入方法依賴的package包/類
@Override
public void onCreate(SQLiteDatabase db) {
    try
    {
        db.execSQL(DATABASE_CREATE);
    }
    catch(SQLException e)
    {
        e.printStackTrace();
    }
}
 
開發者ID:ruiqiao2017,項目名稱:Renrentou,代碼行數:12,代碼來源:HisDatabaseAdapter.java

示例11: onCreate

import android.database.SQLException; //導入方法依賴的package包/類
@Override
public void onCreate(SQLiteDatabase db)
{
    try {
        db.execSQL(DATABASE_CREATION);
    }
    catch (SQLException e) {
        e.printStackTrace();
    }
}
 
開發者ID:marco97pa,項目名稱:punti-burraco,代碼行數:11,代碼來源:ScoreDB.java

示例12: onCreate

import android.database.SQLException; //導入方法依賴的package包/類
public void onCreate(SQLiteDatabase db) {
    try {
        db.execSQL(CREATE_MAINTABLE_HIDES);
    } catch (SQLException e) {
        FirebaseCrash.report(e);
        e.printStackTrace();
    }
}
 
開發者ID:pooyafaroka,項目名稱:PlusGram,代碼行數:9,代碼來源:hideDBAdapter.java

示例13: onCreate

import android.database.SQLException; //導入方法依賴的package包/類
public void onCreate(SQLiteDatabase db) {
    try {
        db.execSQL(userDBAdapter.CREATE_MAINTABLE_USER);
    } catch (SQLException e) {
        FirebaseCrash.report(e);
        e.printStackTrace();
    }
}
 
開發者ID:pooyafaroka,項目名稱:PlusGram,代碼行數:9,代碼來源:userDBAdapter.java

示例14: onCreate

import android.database.SQLException; //導入方法依賴的package包/類
public void onCreate(SQLiteDatabase db) {
    try {
        db.execSQL(changesDBAdapter.CREATE_MAINTABLE_CHANGES);
    } catch (SQLException e) {
        FirebaseCrash.report(e);
        e.printStackTrace();
    }
}
 
開發者ID:pooyafaroka,項目名稱:PlusGram,代碼行數:9,代碼來源:changesDBAdapter.java

示例15: onCreate

import android.database.SQLException; //導入方法依賴的package包/類
public void onCreate(SQLiteDatabase db) {
    try {
        db.execSQL(CREATE_MAINTABLE_CATS);
    } catch (SQLException e) {
        FirebaseCrash.report(e);
        e.printStackTrace();
    }
}
 
開發者ID:pooyafaroka,項目名稱:PlusGram,代碼行數:9,代碼來源:categoryDBAdapter.java


注:本文中的android.database.SQLException.printStackTrace方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。