Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Contributor
Posts: 7
Registered: ‎06-07-2011
My Device: 9800
My Carrier: BD
Accepted Solution

Sqlite problem... showing ? instead of é

Hi All,

I am really stuck with the following problem. Anyone please help.


I have created a database using sqlite.
Created a table named People with attribute Nombre.
Inserted value in the following way:

String sql = "INSERT INTO People('Nombre') VALUES ('César')"; 
//special character 'é'
Statement st = d.createStatement(sql);
st.prepare();
st.execute();
st.close();

 

No problem so far. But when I am trying to show the value from database its showing me '?' insteas of 'é'
I am trying with this ways:

Statement st = d.createStatement("SELECT Nombre FROM People");
st.prepare();
Cursor c = st.getCursor();
while(c.next())
{
    Row r = c.getRow();
    
    String name = r.getString(0);
    System.out.println(name);
    //showing C?sar

    String name1 = new String(name.getBytes("ISO-8859-1"), "UTF-8");
    System.out.println(nameOk1);
    //showing C?sar                      
}
d.close();  

 I have also tried the approach suggested by Peter.
But still its showing '?'

I am now really confused what to try next.
Please help me with solution or any suggestion.

Thanks in Advance

New Contributor
Posts: 7
Registered: ‎06-07-2011
My Device: 9800
My Carrier: BD

Re: Sqlite problem... showing ? instead of é

Anyone please help.

 

Thanks in Advace

 

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Sqlite problem... showing ? instead of é

Have you transferred the database to another platform and confirmed that the actual data is as you expect? 

New Contributor
Posts: 7
Registered: ‎06-07-2011
My Device: 9800
My Carrier: BD

Re: Sqlite problem... showing ? instead of é

Hi Peter,

 

Yes, I have tried the same dataset in mysql. 

Its working fine there.

 

Also from my bb application using sqlite, I guess(not sure) data in inserted acqurately because I can retrive the data using attribute containing special character(ú) like:

 

select Número from People.

This query returns the rows but not showing the expected values.

 

Thanks in Advance

 

 

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Sqlite problem... showing ? instead of é

[ Edited ]

And you have tried this workaround too?

 

http://supportforums.blackberry.com/t5/Java-Development/UTF8-encoding-and-SQLite-database-problems/m...

 

To be honest, if this code doesn't work, i don't know what will. 

New Contributor
Posts: 7
Registered: ‎06-07-2011
My Device: 9800
My Carrier: BD

Re: Sqlite problem... showing ? instead of é

[ Edited ]

Hi Peter,

 

Yes I have also tried that workaround before posting here but with no luck. Man Sad

 

During inserting to db I have used normal string like:

String sql = "INSERT INTO People('Nombre') VALUES ('César')";
Statement st = d.createStatement(sql);
st.prepare();
st.execute();

Do I have to change the qurery string(sql) to UTF-8 or something during inserting into the database?

 

Thanks in Advance

Highlighted
New Contributor
Posts: 7
Registered: ‎06-07-2011
My Device: 9800
My Carrier: BD

Re: Sqlite problem... showing ? instead of é

[ Edited ]

Hi Peter,

 

Problem solved.

 

Actually I was creating the sqlite database from a csv(converted from a excel file) file using bb code.

Now I have tried fresh by creating a new csv from my mysql database. Inserted into sqlite from that file.

And know what your workaround worked like a champ. Man Happy

 

Thank you very much.