0

I have a table named "statuses" in my MySQL database which looks like this:

| "id" (int) | "text" varchar(50) | "hex_color" varchar(10) |
-------------------------------------------------------------
| 1          | EJ PÅBÖRJAD        | #FF3300                 |
| 2          | ARBETE PÅGÅR       | #FFFF00                 |
| 3          | AVVAKTAR           | #80F0FF                 |
| 4          | ÅTGÄRDAD           | #6DE37A                 |
-------------------------------------------------------------

Here's my JDBC Java-code:

Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(statement);

while(rs.next()){
   Long pid = rs.getLong(1);
   String ptext = rs.getString(2);
   String hex_color = rs.getString(3);

   status = new Statuses(pid, ptext, hex_color);
}

When statement is:

SELECT id, text, hex_color FROM statuses WHERE text = 'EJ PÅBÖRJAD' - 1 result

SELECT id, text, hex_color FROM statuses WHERE text = 'ARBETE PÅGÅR' - 0 result

SELECT id, text, hex_color FROM statuses WHERE text = 'AVVAKTAR' - 1 result

SELECT id, text, hex_color FROM statuses WHERE text = 'ÅTGÄRDAD' - 1 result

why do i get 0 result on the second statement? when i'm running it myself in "mysql command line" i get 1 result! i've checked that i'm using the same charset (UTF-8) which rules out charset problem.

can someone please help me on this matter?

kind regards, Clyde

3
  • Try printing the statements before executing them in the code. that may help you to debug Commented Nov 2, 2012 at 11:09
  • I've already done that. It says SELECT id, text, hex_color FROM statuses WHERE text = 'ARBETE PÅGÅR' before it executes Commented Nov 2, 2012 at 11:14
  • See here Commented Nov 2, 2012 at 12:41

2 Answers 2

1

Are you absoluty sure that

  • you haven't made a copy-paste error for 'ARBETE PÅGÅR' or
  • the database contains an extra space or other unprintable character in/after 'ARBETE PÅGÅR'

Try surrounding with wildcards, eg. SELECT * FROM statuses WHERE text LIKE '%ARBETE%PÅGÅR%' and see if that makes a difference?

Cheers,

Sign up to request clarification or add additional context in comments.

1 Comment

The statement is genereted by the website. all i'm doing is copying the generated statement which fails, running it myself and i get 1 result. wildcards doesn't work either. screw swedish, i'll change the status text to english instead. thanks for your time
0

I know it's a 7 months old post but I thinks you could check if you have committed after you inserted those rows.
When you run the query yourself, you are probably using the same session that you used to insert those rows. That's why you can see them.
Until you commit, other users won't be able to see the effect(of the inserts).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.