aspose file tools*
The moose likes JDBC and the fly likes database problematics Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "database problematics" Watch "database problematics" New topic
Author

database problematics

krillian konstatos
Ranch Hand

Joined: Jan 03, 2011
Posts: 49

i am learning how to use the java derby database as an embedded db in my applications. i know the basics of
jdbc programming and have used a little jdbc both in application and web environments but i have
some doubts about wheter or not i should fully use jdbc in my application development. i really want to take on the role
as a practitioner in java database application development. up to now i have only used xml as a database
and plain text files to store my user input and it has always worked for me and suited my needs to store user input in
my applications, but now i feel ready to go one step further and start to use jdbc instead, am i resasoning right in this
way? what are the up and downsides in using jdbc instead of xml as a database and vice versa? could someone
point at some issues regarding this matter that i am so concerned with?

regards,
krillian!
Manish Singh
Ranch Hand

Joined: Jan 26, 2007
Posts: 160
You should start using JDBC because most of the projects will need to store the data in the database.
krillian konstatos
Ranch Hand

Joined: Jan 03, 2011
Posts: 49

i have used xml and DOM to store my user data in my applications since i am not that comfortable with database programming jdbc seems so advanced for me but i have decided that i must start to use it sometime. i am reading a lot about how to set up the derby and use it in an embedded way. i'd appreciate if someone could post links to articles and examples concerning this topic.
Phil Freihofner
Ranch Hand

Joined: Sep 01, 2010
Posts: 115
    
    1
Derby's manual:
http://db.apache.org/derby/docs/10.6/ref/refderby.pdf

If you can get yourself a copy of Horstmann's Core Java, vol. II, the database chapter includes Derby examples. I think it is on Safari's online tech library. I like both volumes very much, have purchased each.

But there's also good, free stuff in the Java Tutorial area:
http://download.oracle.com/javase/tutorial/jdbc/index.html
This is how Java communicates with a database, sending commands through the JDBC.

Good luck!

krillian konstatos
Ranch Hand

Joined: Jan 03, 2011
Posts: 49

hello ranch!

i am very glad för the replies it has helped me a lot. i am still facing a lot of difficulties when it comes to setting up the class path for the derby driver when i intend to use it in my on projects not just in them found in the tutorials. i think i am missing something big here but im not sure what it is. lets say i have a project called project main directory "myprj" which resides in my main folder for my java applications. in the folder myprj i want to have a subfolder named after the main class called for example "mymain" and in mymain i want to place the derby jar file in a folder called lib so the path to the derby directory would be



i also intend to have a directory in mymain in which i want to place the class which instantiate the connection to the derby database driver and i call this class "Connector" which i place in a directory called "db" directly under the myprj.mymain folder. this is where i am totally confused when it comes to load the driver correctly in the driver url. how do i tell the drivermanager where it should look for the derby jar file? i have tested this with the following url




My problem is that i dont know how to add the derby jar which is placed in the db folder. my main class is placed in the default directory directly under the myprj folder. how will i then deploy the app so that the driver loads correctly on a another users machine? i am a beginner within jdbc programming and i am completely lost here i cant even get the example in the tutorial work right so it suits my own urls to the location of the derby jar file. if someone could help me how to do this i'd be so thankful. i dont know how to hard code my own url to where i have placed the jar file in the connection url in the
DriverManager.getConnection method. i must add that i have read the derby manual that comes with the zip package and the jdbc tutorial but i still cant get anything to work manually and not just in a tutorialized way

regards,
krillian!
krillian konstatos
Ranch Hand

Joined: Jan 03, 2011
Posts: 49

since i have started to learn more and more about ant and classpath issues in java, i read everything i can find about theese topics, i am getting a clearer picture of the solution to this problem of mine. i have always disliked command line utilities but i am starting to become a beliver after all.
 
 
subject: database problematics