Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9253225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:09:52+00:00 2026-06-18T11:09:52+00:00

I have a couple of columns in my database which has been annotated as

  • 0

I have a couple of columns in my database which has been annotated as uniqueCombo=true

@DatabaseField(columnName = "COL1", uniqueCombo = true)
private Double col1;

@DatabaseField(columnName = "COL2", uniqueCombo = true)
private Double col2;

According to ormlite documentation the combination of these two fields should be unique in the table. To test this I am purposely adding same fields. I do get the SQLException but am not sure how do I handle this exception and ask the user to make changes.

try {
        mydao.create(myInfo);

     } catch (SQLException e) {
        // TODO Auto-generated catch block

       e.printStackTrace();
       /* Need to uniquely identify constraint failed error here
        * and ask user to make suitable change */
     }

Any idea how this can be accomplished.

— UPDATE —

SQLException getErrorCode and getSQLState both return 0 and null respectively.

Logcat StackTrace:

Caused by: android.database.sqlite.SQLiteConstraintException: column NAME is not unique (code 19)
01-31 22:15:14.042: W/System.err(2586):         at android.database.sqlite.SQLiteConnection.nativeExecuteForLastInsertedRowId(Native Method)
01-31 22:15:14.042: W/System.err(2586):         at android.database.sqlite.SQLiteConnection.executeForLastInsertedRowId(SQLiteConnection.java:775)
01-31 22:15:14.042: W/System.err(2586):         at android.database.sqlite.SQLiteSession.executeForLastInsertedRowId(SQLiteSession.java:788)
01-31 22:15:14.042: W/System.err(2586):         at android.database.sqlite.SQLiteStatement.executeInsert(SQLiteStatement.java:86)
01-31 22:15:14.042: W/System.err(2586):         at com.j256.ormlite.android.AndroidDatabaseConnection.insert(AndroidDatabaseConnection.java:122)
01-31 22:15:14.042: W/System.err(2586):         ... 15 more
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T11:09:53+00:00Added an answer on June 18, 2026 at 11:09 am

    I do get the SQLException but am not sure how do I handle this exception and ask the user to make changes.

    You can certainly catch the exception and see if it is instanceof SQLiteConstraintException but I always hate treating exceptions as common occurrences.

    What I would do is do a query on the user’s input to see if there is an existing MyInfo object with the same fields. Something like the following:

    QueryBuilder<MyInfo, Integer> qb = mydao.queryBuilder();
    qb.where().eq("COL1", myInfo.col1).and().eq("COL2", myInfo.col2);
    if (qb.queryForFirst() != null) {
       // tell the user to enter unique values
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a couple of columns (ip, provider_id) for which I want combinations of
I have several tables in my database and want to select a couple columns
I have a database table where each row (movie) has a couple of numeric
I have a couple of columns in jqGrid with edittype=select. How can I read
I have a gridview with couple of columns,I want to achieve the following: If
suddenly we have to save kanji (Japanese) in a couple of columns of two
I have couple of formulas and data coming from database. I want to refresh
I have a couple of CSV files I want to load into my database,
I have been looking for a some working code for the last couple of
need help from some gurus here, I have a database which I have moved

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.