aspose file tools*
The moose likes JDBC and the fly likes A bit stuck with my small database design Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "A bit stuck with my small database design" Watch "A bit stuck with my small database design" New topic
Author

A bit stuck with my small database design

Kristjan Toots
Ranch Hand

Joined: Jun 03, 2011
Posts: 59

Hello.
I'm fairly new to the programming and I am still facing difficulties with OOP based concepts. I am trying to build a small standalone swing application with some database functions. I would be thankful for any kind of pointers and I appreciate any discussion on topic.

What I have so far:
I had in mind that I would create Database class what is responsible for starting my hsql server & making connection to it. Then I thought I would create a separate class where I do all the writing and reading from. Am I going towards the right direction? I've read about MVC design pattern but I can't apply it here can I?

I tried to play around with private static Connection connection object. I thought that when I make it static there would be only one of those. So I could pass that to different class and in such way I can accomplish doing writing / reading from separate class. Ended up with
Server@8813f2]: [Thread[HSQLDB Server @8813f2,5,main]]: run()/openServerSocket():
java.net.BindException: Address already in use: JVM_Bind




I've created Database class like this:



Please correct my english.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18140
    
    8

So why did you only make those two variables static? Why aren't the other two variables static, for the same reason? And the methods which use those variables, why aren't they static?
Kristjan Toots
Ranch Hand

Joined: Jun 03, 2011
Posts: 59

Paul Clapham, thank you for your reply.
I don't know why I forgot to make those methods static aswell, anyway, your kind guidance steered me towards a solution.

I remember from somewhere that using a lot of static methods is not recommended. Now, when I have static methods all over the place I don't feel so pleased about my approach like I thought I would.

I'm thankful for suggestions how I should rearrange things. : )
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: A bit stuck with my small database design
 
Similar Threads
NullPointerException on getServletContext
Resultset processes 1 record
How to close db connection
SQL Server 2008r2 Connection Failed
SQLServerException - could not connect to the host on port 1433