| Author |
jdbc with as400
|
Tony Lavalle
Ranch Hand
Joined: Jan 18, 2005
Posts: 36
|
|
I am trying to connect to our as400 to do some custom reports. I have coded this java app import java.sql.*; import java.io.*; public class dbConnect { public static void main(String[] args) throws IOException { Connection con = null; try { class.forName("com.ibm.as400.access.AS400JDBCDriver").newInstance(); // Create a connection to the database con = DriverManager.getConnection("jdbc:as400://10.220.0.1", "sotony", "lavalle"); if(!con.isClosed()) { System.out.println("Successfully connected to the AS/400..."); } } catch (ClassNotFoundException e) { // Could not find the database driver System.out.println("Could not find db driver"); } catch (SQLException e) { // Could not connect to the database System.out.println("Could not connect to db"); } catch (Exception e) { // General Error System.out.println("Error"); } } } i keep getting these for errors what am I doing wrong? C:\Program Files\Java\jdk1.5.0_09\projects\dbConnect\src\dbConnect.java:19: <identifier> expected class.forName("com.ibm.as400.access.AS400JDBCDriver").newInstance(); ^ C:\Program Files\Java\jdk1.5.0_09\projects\dbConnect\src\dbConnect.java:19: '{' expected class.forName("com.ibm.as400.access.AS400JDBCDriver").newInstance(); ^ C:\Program Files\Java\jdk1.5.0_09\projects\dbConnect\src\dbConnect.java:22: <identifier> expected con = DriverManager.getConnection("jdbc:as400://10.220.0.1", "sotony", "lavalle"); ^ C:\Program Files\Java\jdk1.5.0_09\projects\dbConnect\src\dbConnect.java:23: illegal start of type if(!con.isClosed()) ^ C:\Program Files\Java\jdk1.5.0_09\projects\dbConnect\src\dbConnect.java:27: <identifier> expected } ^ C:\Program Files\Java\jdk1.5.0_09\projects\dbConnect\src\dbConnect.java:29: 'catch' without 'try' catch (ClassNotFoundException e) ^ C:\Program Files\Java\jdk1.5.0_09\projects\dbConnect\src\dbConnect.java:18: 'try' without 'catch' or 'finally' try { ^ C:\Program Files\Java\jdk1.5.0_09\projects\dbConnect\src\dbConnect.java:45: '}' expected
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26192
|
|
Tony, class.forName should be Class.forName - note the capital C. I think this is causing some of the later errors. Try fixing it and see what errors (if any) you get then.
|
[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
|
 |
Tony Lavalle
Ranch Hand
Joined: Jan 18, 2005
Posts: 36
|
|
|
Thank you. I can not believe i missed that.
|
 |
 |
|
|
subject: jdbc with as400
|
|
|