Article View: borland.public.jbuilder.java.language
Article #14463Re: can someone tell me what is wrong!!!??
From: Colin Cooper
Date: Wed, 01 Sep 1999 00:00
Date: Wed, 01 Sep 1999 00:00
173 lines
6323 bytes
6323 bytes
ngumba,
The problem is not that the compiler can't find the println method, but that
it cannot find one with the parameter list you are supplying:
System.out.println(CUSTFNAME, CUSTLNAME, SOCIALSECURITYNUMBER,
ADDRESS, TELEPHONE, MONEYOWED);
i.e. println(String,String,int,String,int,int);
try
System.out.println(CUSTFNAME+","+CUSTLNAME+","+SOCIALSECURITYNUMBER+","+,
ADDRESS+","+TELEPHONE+","+MONEYOWED);
as a quick fix, or look at the formatters in the java.text package.
Regards,
Colin Cooper
ngumba nyika wrote:
> the following code is one i have been testing for 3-4 hours now and i
> have already created the "dev4.gdb" database structure and i have
> created columns and put data into them (experimental data). The columns
> are CUSTFNAME, etc. I am running Interbase5 and the java ide is
> JBuilder3 . The only error i receive is that the
> "System.out.println(CUSTFNAME,.....)" line is faulty, more specifically
> that JBuilder cannot find the method "println" in java.io.printStream.
> I have tried everything ( well, almost). Please anyone help me before i
> go mad.....i am on the edge of it all. Thanx in advance.
> nyix
>
> import java.sql.*;
> import java.util.*;
> import java.io.*;
> /**
> * This class should be used to test that you can connect through JDBC
> to your database.
> * Before testing if you can connect through TOPLink you MUST ensure
> that you can connect
> * to JDBC outside TOPLink. If you cannot connect through JDBC contact
> your system administrator,
> * JDBC driver provider, or your Java IDE provider to figure out why.
> * <p>
> * Possible Reason Include:
> * <ul>
> * <li> You have not installed the JDBC driver correctly.
> * <li> You are using a JDBC-ODBC driver and have not install ODBC
> correctly.
> * <li> Your IDE does not support the JDBC driver that you are using.
> * <li> You have not provided the correct connection information to the
> driver.
> * </ul>
> */
>
> public class JDBCConnectTest {
>
> /**
> * Test connecting to the database.
> * You should put your own connection information here and run this
> class.
> */
>
> public static void connect(JDBCConnectTest test)
> {
>
> System.out.println("Starting to connect...\n");
>
> String driverClassName = test.getDriverClassName(); // Insert
> your JDBC driver class name here.
> String databaseURL = test.getDatabaseURL(); // Insert your JDBC
> URL here.
> Properties properties = test.getProperties(); // This should
> contain any additional information your database requires.
>
> try { // This ensures that the driver has been loaded and
> registered.
> Class.forName(driverClassName);
> System.out.println("........found the driver\n");
> } catch (ClassNotFoundException exception) {
> throw new RuntimeException("Configuration error. Class "
> + driverClassName + " not found.");
> }
>
> Connection newConnection;
> try {
> newConnection = DriverManager.getConnection(databaseURL,
> properties);
> System.out.println("Connection successful.");
>
> Statement select = newConnection.createStatement();
> ResultSet result = select.executeQuery("SELECT * FROM CUSTOMER");
> System.out.println("First Name Last Name Social Number Address
> Telephone Money Owed");
>
> while(result.next())
> {
> String CUSTFNAME = result.getString(1);
> String CUSTLNAME = result.getString(2);
> int SOCIALSECURITYNUMBER = result.getInt(3);
> String ADDRESS = result.getString(4);
> int TELEPHONE = result.getInt(5);
> int MONEYOWED = result.getInt(6);
> System.out.println(CUSTFNAME, CUSTLNAME, SOCIALSECURITYNUMBER,
> ADDRESS, TELEPHONE, MONEYOWED);
> }
>
> select.close();
> newConnection.close();
>
> } catch (SQLException exception) {
> throw new RuntimeException("A database error occured at
> login, " + exception.getMessage());
> }
>
> System.out.println("Starting to disconnect...");
> try {
> newConnection.close();
> } catch (SQLException exception) {
> throw new RuntimeException("A database error occured at
> logout, " + exception.getMessage());
> }
> System.out.println("Disconnection successful.");
> }
> /**
> * Insert your JDBC URL here.
> */
>
> public String getDatabaseURL()
> {
> //return "jdbc:odbc:Limo";
> //return "jdbc:oracle:oci8:@dev";
> return "jdbc:interbase://localhost/c:/interbase5/tutorial/dev4.gdb";
>
> }
> /**
> * Insert your JDBC driver class name here.
> */
>
> public String getDriverClassName()
> {
> //return "sun.jdbc.odbc.JdbcOdbcDriver";
> //return "oracle.jdbc.driver.OracleDriver";
> return "interbase.interclient.Driver";
> }
> /**
> * This should contain any additional information your database
> requires.
> */
>
> public Properties getProperties()
> {
> Properties properties = new Properties();
> properties.put("user", "tutor");
> properties.put("password", "tutor");
> //properties.put("server", "192.168.5.200:1521");
> //properties.put("database", "dev");
>
> return properties;
> }
> /**
> * Test connecting to the database.
> * You should put your own connection information here and run this
> class.
> */
>
> public static void main(String[] args)
> {
>
> connect(new JDBCConnectTest());
> }
> }
Technical Details
Message-ID:
<37CD1143.1BFF4C38@summon.demon.co.uk>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<37A73517.CC285AFD@softhome.net>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,780fe5867aa8f72b X-Google-Attributes: gidf74b3,public From: Colin Cooper <colin@summon.demon.co.uk> Subject: Re: can someone tell me what is wrong!!!?? Date: 1999/09/01 Message-ID: <37CD1143.1BFF4C38@summon.demon.co.uk> X-Deja-AN: 519694745 Content-Transfer-Encoding: 7bit References: <37A73517.CC285AFD@softhome.net> To: nyix@softhome.net X-Accept-Language: en Content-Type: text/plain; charset=us-ascii Organization: Another Netscape Collabra Server User Mime-Version: 1.0 Newsgroups: borland.public.jbuilder.java.language