aspose file tools*
The moose likes Cattle Drive and the fly likes To Students on JDBC Assignment 2a Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » This Site » Cattle Drive
Bookmark "To Students on JDBC Assignment 2a" Watch "To Students on JDBC Assignment 2a" New topic
Author

To Students on JDBC Assignment 2a

Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9047
    
  10
Please look at the assignment page. Test the new ant target and tell me if you experience any problems.

Thanks.


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Matt Fry
Ranch Hand

Joined: Mar 06, 2006
Posts: 60
Sorry it took me so long to see this, Marilyn. Anyway, I couldn't seem to get it to work. I sent you an email detailing the problem I am having. I'm sure it's probably me doing something wrong.
Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1197
Me, too. I just got the go-ahead for the next assignment, and I'm looking at the instructions for it. Probably won't have a block of time large enough until this weekend. Thanks!
Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1197
Of course, that means that, as we did with the deploy target, we need to add these properties to our properties file.

Uhhh, which properties file do you mean? The one named videos.properties, which is in C:\java\videos\ or the one we created that goes into the home directory?
And this would be something like:
"sql.dir=/java/videos/src/db"
I'm not sure what I need to do here.
[ March 08, 2007: Message edited by: Carol Murphy ]
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9047
    
  10
Originally posted by Carol Murphy:
Uhhh, which properties file do you mean? The one named videos.properties, which is in C:\java\videos\ or the one we created that goes into the home directory?
And this would be something like:
"sql.dir=/java/videos/src/db"
I'm not sure what I need to do here.

Hmmm. You will have 3 properties files ... build.properties, videos.properties, and carol.properties, but none of them go directly into the C:\java\videos directory. According to the page about properties files, build.properties and videos.properties both go into the same directory (user.home) which, if you're using Windows 2000, XP, or Vista, should be in something like C:\Documents and Settings\<your windows login name>. The carol.properties file would go into the directory that looks like C:\Java\videos\config.

You're correct on the sql.dir property.
Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1197
I must have missed something somewhere, because I do not have a config directory in C:\java\videos\ , nor do I have a carol.properties file anywhere on my hard drive. Should I create a config folder and then a carol.properties file with the appropriate code inside? Did I overlook some part of the instructions somewhere along the line?
Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1197
Okay, I think I've done the right thing here. I created a folder in my development directory to put my properties file in, but I'm not sure how to define db.driver.jar. Could this be as simple as pointing db.driver.jar to the location of the JDBC Driver I'm using? Can java statements be used inside the properties file? I'm thinking if I can put the Class.forName( "name.for.database.driver" ) ; statement in my properties file, then I can define db.driver.jar. Or am I way off base?
[ March 11, 2007: Message edited by: Carol Murphy ]
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9047
    
  10
Read this article on evil ant properties and see if it helps make properties files any clearer. I also updated the assignment page again to try to clarify things a bit more.
[ March 11, 2007: Message edited by: Marilyn de Queiroz ]
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9047
    
  10
... I'm not sure how to define db.driver.jar. Could this be as simple as pointing db.driver.jar to the location of the JDBC Driver I'm using?

Yes

Can java statements be used inside the properties file?

no
Matt Fry
Ranch Hand

Joined: Mar 06, 2006
Posts: 60
I'm confused with this "properties file". I've read the info at the links provided, but it's still clear as mud. I don't know how to create a properties file. What is the syntax of this file? Is there anywhere that shows what an actual properties file is supposed to look like?

TIA.
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9047
    
  10
On the servlets assignment page, under "Deploying to Orion", the preamble to Assignment Servlets-3b, we already created the build.properties file.
Matt Fry
Ranch Hand

Joined: Mar 06, 2006
Posts: 60
Thanks, Marilyn. Everything seems to be working here now!
Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1197
In the current version of JDBC2a, the Driver is loaded by calling the following:
Class.forName( "org.gjt.mm.mysql.Driver" ) ;
But this is not the location of the Driver I am using. I'm thinking I need to put db.driver.jar=C:\MySQLDriver\mysql-connector-java-2.0.14

Am I close?
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9047
    
  10
Close, but you need to include the name of the file (jar) containing the driver ... maybe something more like ...
<code>db.driver.jar=C:\MySQLDriver\mysql-connector-java-2.0.14\mysql-connector-java-2.0.14-bin.jar</code>
??
Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1197
Okay, thanks. That actually makes sense! Part of my confusion stems from not really being able to process all of the terminology, so while everyone else is busy figuring out what to do, I'm struggling with what it means!
Mark Beattie
Greenhorn

Joined: Mar 30, 2006
Posts: 26
Well, I am certainly tuckered out.

I've been attempting to get the new version of JDBC-2a to work. I think I am half way there.

My first comment is that the assignment should tell the student to first read Paul Wheaton's Evil Ant Build Properties article. I suspect most coders are like me in that they try to get something to work by ignoring the instruction manual. Yes, that is how I assemble furniture and children's Christmas gifts.

My second comment relates to where I am stuck. The build.xml very nicely tells me that I need to set my db.driver.jar. I found the answer in the reply to Carolyn's email above. Then it tells me to set the db.driver. Now it wants the url, userid, and password. I have not the foggiest idea what the db.url would be. What are they?

I should explain that I set up MySQL differently from what is described in the first section of the JDBC assignment. MySQL site has been updated since and I was only able to get it to work by setting it up in the Program Files folder as recommended by MySQL. Doing it this way, all I have to do is open the command prompt window and type 'mysql -u root' and MySQL starts up no problem. So I never had to worry about where the MySQL program is located.

Mark Beattie
Greenhorn

Joined: Mar 30, 2006
Posts: 26
Carolyn,

I have no idea what most of the things mean. I just want to make it work.
:roll:

Mark
Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1197
I, too, am a reader of manuals and directions as a last resort.
Unfortunately, I have the kind of mind that balks at what I don't understand. I have to be able to at least fool myself into thinking I get it before I can function comfortably. I must have have driven my parents nuts asking how and why ad nauseum when I was small.
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9047
    
  10
Between Assignment JDBC-1 and Assignment JDBC-2a, there is a section on "Download and install the mysql JDBC driver".

The last line of code here contains the url. The url begins with "jdbc:mysql://" rather than starting with "http://" like the urls you are probably more familiar with.

Take a look at the getConnection() method of DriverManager in the API for more info.
Mark Beattie
Greenhorn

Joined: Mar 30, 2006
Posts: 26
Hello Carol, Matt, and Marilyn,

[Carol, I got your name right this time. Having the names Carol and Marilyn on the same site impels me to use Carolyn, a friend of mine.]

I got a new version of the build.xml working, and my JBDC-2a assignment continues to work. That is not to say that I implemented things correctly. I did not see any evidence that the createVideos.sql actually ran.
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9047
    
  10
It only runs when you tell it to. Instead of typing
"ant" at the command line, try typing "ant db". Then rerun your app (assignment)
Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1197
Uh, I think it might be working. Ant is doing the build right now. Will be back with an update!

It seems to have worked! Now to tackle the LogApp. (Those properties seem too easy. It's like, so simple, it just doesn't seem right!)
[ March 16, 2007: Message edited by: Carol Murphy ]
 
wood burning stoves
 
subject: To Students on JDBC Assignment 2a