aspose file tools*
The moose likes JDBC and the fly likes jdbc with as400 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "jdbc with as400" Watch "jdbc with as400" New topic
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: 29220
    
135

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jdbc with as400
 
Similar Threads
JAVA to JDBC to AS/400 Problem
Problem occurs when using DataSource connection in WSAD
NullPointerException..
connecting to mysql, with java, on a mac
Using JDBC java code - how can I connect to IBM AS400 iSERIES to read data