• Post Reply Bookmark Topic Watch Topic
  • New Topic

JBDC connection and getAllOrders() method  RSS feed

 
Wayne Ritter
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JBDC connection and getAllOrders() method

I have been writing a little APEX, but I was told it would be a good idea to learn JAVA before I continue with APEX. I created a JAVA application and I have a MySQL server / database to connect to. I created an Order Class, OrderDAO Class, and a ConnectionPOOL class. The Order class is the pojo. I'm trying to write a getAllOrders () method in the OrderDAO class (and UPDATE and DELETE), but I can't seem to get it to work. Would anyone mind taking a look?

MyConnectionPool
-----



Order Pojo





Order DAO

I'm getting an error with the statement s and catch?

-------

 
Carey Brown
Saloon Keeper
Posts: 3310
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Whenever you post code please surround it with Code tags. In the editor window highlight (select) your block of code and then click on the "Code" button just above the editor pane. I fixed it for you this time.
 
Carey Brown
Saloon Keeper
Posts: 3310
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I expected to see something at line 20 in your OrderDAO class. You are iterating through "rs" but you are not doing anything with it.
 
Carey Brown
Saloon Keeper
Posts: 3310
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you run this from the MySQL command line utility what do you get? (first few lines)
 
Carey Brown
Saloon Keeper
Posts: 3310
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Given this commented out line of code

I would expect your DAO class to have at least the following fields: id, name, and createdDate.
I would expect that you would construct a DAO object with the data in the result set.
I would expect the constructed DAOs to be gathered up in a List<OrderDAO>, and that this list would be returned from the method.
you should provide a toString() method to print out the state of the fields and then use that in place of this println() construct.

Edit: Went back to your code and I forgot that you had an "Order" class, so that should be used in my preceding comments.
 
Carey Brown
Saloon Keeper
Posts: 3310
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!