This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jdbc with as400

 
Tony Lavalle
Ranch Hand
Posts: 36
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33696
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you. I can not believe i missed that.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic