aspose file tools*
The moose likes JDBC and the fly likes Starting to open the connection at the beginning of the class 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 "Starting to open the connection at the beginning of the class" Watch "Starting to open the connection at the beginning of the class" New topic
Author

Starting to open the connection at the beginning of the class

Nico Yukiko
Greenhorn

Joined: Aug 24, 2005
Posts: 21
How come i can't place the try at the start of a new class and the code below is giving me a problem.and regarding declaring an array to store the info in the database to replace the static code at the bottom is also giving problem.



[edited to add code tags]
[ August 24, 2005: Message edited by: Jeanne Boyarsky ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61426
    
  67

Basic Java. All executable statements must be within a method.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Nico Yukiko
Greenhorn

Joined: Aug 24, 2005
Posts: 21
But how can i separate the code into a method and then call the method
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30762
    
156

Nico,
Welcome to JavaRanch!

I'm guessing you want to run this as a standalone program. In that case, add the line:

before the first "try {". And then close the brace with a } at the end of the code.

To call it, you can then do "java Catalog" from the command line.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Nico Yukiko
Greenhorn

Joined: Aug 24, 2005
Posts: 21
But how can i store the information retrieve from the database into an array so that i can create a new catalog item base on the array
Stephen Boston
Ranch Hand

Joined: Jul 14, 2005
Posts: 165
You may want to check out ArrayList.

LearnJDBC


Steve<br /> <br />No matter where you go, there you are.<br /> <br />"My evil self is at the door, and I have no power to stop it."
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Starting to open the connection at the beginning of the class