• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

jdbc with as400

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
author & internet detective
Posts: 41919
910
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Tony Lavalle
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you. I can not believe i missed that.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic