|
Hi,
I'm tring to create an applet that using jt400 classes to read an AS400
file.
The com.ibm.as400.access.AS400JDBCDriver() registation is OK!
but the getConnection (Connection connection = DriverManager.getConnection
("jdbc:as400://S655772B/CGIUTI;naming=system;errors=full;libraries=CGIUTI,QGPL;date
format=iso",userString,passwordString);) return null Exception and doesn't
read the file (there are no errors in JVM consolle!)
Here's the code :
//***********************************************************
import java.lang.Object.*;
import java.net.URLConnection.*;
import java.net.URL.*;
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import com.ibm.as400.access.*;
import java.sql.*;
public class AccessoDB extends Applet implements ActionListener
{
Label systemPrompt;
Label userPrompt;
Label passwordPrompt;
TextField systemField;
TextField userField;
TextField passwordField;
Button okButton;
Button cancelButton;
String systemString;
String userString;
String passwordString;
String commandString;
public void init()
{
setLayout(new FlowLayout());
systemPrompt = new Label("Nome Sistema AS400 ");
add(systemPrompt);
systemField = new TextField(15);
add(systemField);
userPrompt = new Label("Utente");
add(userPrompt);
userField = new TextField(10);
add(userField);
passwordPrompt = new Label("Password");
add(passwordPrompt);
passwordField = new TextField(10);
add(passwordField);
okButton = new Button("OK");
okButton.addActionListener(this);
add(okButton);
cancelButton = new Button("Cancel");
cancelButton.addActionListener(this);
add(cancelButton);
}
public void paint(Graphics g)
{
if ((systemString != null) &&
(userString != null) &&
(passwordString != null))
{
g.drawString("Sistema:" + systemString, 60, 100);
g.drawString("Utente:" + userString, 60, 120);
g.drawString("Connessione a Host ...", 60, 160);
g.drawString("Connessione a CGIUTI ...", 60, 180);
String system=systemString;
try
{
// Load the IBM Toolbox for Java JDBC driver.
DriverManager.registerDriver(new
com.ibm.as400.access.AS400JDBCDriver());
g.drawString("Driver OK!.", 60, 200);
Connection connection = DriverManager.getConnection
("jdbc:as400://S655772B/CGIUTI;naming=system;errors=full;libraries=CGIUTI,QGPL;date
format=iso",userString,passwordString);
g.drawString("Connessione OK!.", 60, 220);
DatabaseMetaData dmd = connection.getMetaData ();
Statement select = connection.createStatement ();
ResultSet rs = select.executeQuery ("SELECT * FROM CGIUTI"
+ dmd.getCatalogSeparator() + "WLUTE00F");
g.drawString("Connessione Query!.", 60, 240);
ResultSetMetaData rsmd = rs.getMetaData ();
int columnCount = rsmd.getColumnCount ();
StringBuffer dashedLine;
while (rs.next ()) {
for (int i = 1; i <= columnCount; ++i) {
String value = rs.getString (i);
if (rs.wasNull ())
value = "<null>";
g.drawString(value, 60, 260);
}
}
connection.close();
}
catch (Exception e)
{
g.drawString("Connessione Fallita."+ e.getMessage(), 60, 220);
}
}
}
public void actionPerformed(ActionEvent e)
{
if (e.getActionCommand() == "Cancel")
{
System.exit(0);
}
systemString = systemField.getText();
userString = userField.getText();
passwordString = passwordField.getText();
repaint();
}
}
// end of Code ****************************************************
P.S.:In the same jar file are saved all jt400 classes needed!
Thanks in advance!!
Vincenzo Amoruso
System Project s.r.l.
Andria(BA) - Italy
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.