• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Java&sql mystical problem with Switch

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First, I am sorry about my broken English.
I have created simple project manager software with MySql and Java and I got this little problem.


my problem: : java.sql.SQLException: No row count was produced
-so there is something wrong in my code, but I can�t find out what is wrong
If I do those sql-clauses without switch they work.

This is what i am trying to do: Sql-clause should check is there this days(2004-07-29) field in database if there is sql-clause should only update hours(user given) of the day, but if there is not this days field sql-clause should create it. That�s why I need switch.



I have tried to resolve this problem days.
If someone could please help me
 
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Torsti,
well, this doesn''t look like standard JDBC to me at all! That would answer why no one has replied to your request for help. They can't help you.

Here's why I think your using non-standard JDBC.
Firstly,
in JDBC, you supposed to get an object that implements the Connection interface from a DriverManager, or from a DataSource. In your code, you just new a Connection() class, so I suspect somebody where you work wrote a very special Connection class to allow other developers to retrieve a connection easily (they probably did this to do connection pooling, but of course, that is a guess).

Second thing,
we don't know what your special Connection class does, but you are calling updatdeQuery() on it. In standard JDBC, you would get a PreparedStatement from the connection, or at least a Statement, and then call executeUpdate() or executeQuery() on that. So now, we can see your using a non-standard way of executing SQL statements.
-----------------
Having said that, I suspect your call to conn.updateQuery(sqlClause) is not returning 0 or 1 at all, which is what you are assuming in your 'switch'. You need to put in a "default:" section into the 'switch' statement. Inside the "default:" section, write something like:
System.out.println("default: called, updateQuery() not returning 0 or 1");

-Jeff Walker
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Torsti,
Watch the scope of your variables. The strings declared inside the switch statement are only valid in the switch statement.

I would go with an if statement rather than the switch. That way you can do an if/else to account for the two conditions without having to use a default case.
 
Do not threaten THIS beaver! Not even with this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic