| Ver tema anterior :: Ver siguiente tema | | Autor | Mensaje |
|---|
jaorsoftware
Registrado: 09 Jul 2007 Mensajes: 1
| Publicado: 09/07/2007 11:02 pm | | | Título: error 32 <identifier> expected |
| COLEGAS.
ESTOY INICIANDOME EN JAVA.
TENGO UNA CLASE EN LA QUE DECLARO EL ACCESO A UNA BASE DE DATOS. POSTERIORMENTE EN OTRA CLASE QUIERO UTILIZAR LOS METODOS UTILIZADOS EN LA CLASE PERO NO ME LO PERMITE, ME MARCAR EL ERROR DE IDENTIFIER EXPECTE.
UNICAMENTE USANDO EL CONSTRUCTOR NO ME MARCA ERROR, PERO EN ESTA CLASE VOY A DEFINIR TODOS LOS METODOS DE ACCESO A LA BASE DE DATOS Y TENGO QUE PODER UTILIZARLOS PERO NO HE PODIDO CON ESTE ERROR.
ESTA ES LA CLASE QUE ESTA EN EL ARCHIVO java2101.java
package TimeControl;
// java2101.java
import java.sql.*; import java.lang.*; import javax.swing.*;
public class java2101 { //Variable to operate DB Connection connDBTIMER; Statement statSQL; ResultSet resuResult; String strCurDir; String strDBDriver;
public java2101() {
// Try load driver JDBC-ODBC try { Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" ); JOptionPane.showMessageDialog(null,"! Driver Loaded !");
} catch( Exception e ) { //Display Message Error JOptionPane.showMessageDialog(null,"ErrorDB-00:Can't Load JDBC-ODBD-"+e); return; }
try {
// Get Path strCurDir = System.getProperty("user.dir")+"\\"+"dist\\JaorTIMER.mdb";
// Build Driver strDBDriver = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ="+strCurDir;
// Connect to DB connDBTIMER = DriverManager.getConnection( strDBDriver,"","" );
// JOptionPane.showMessageDialog(null,"! Connection Maked !");
return;
} catch( Exception e ) { //Display Message Error JOptionPane.showMessageDialog(null,"ErrorDB-01:"+e); return; } }
public void SubCloseConnection() { try { connDBTIMER.close(); } catch( Exception e ) { //Display Message Error JOptionPane.showMessageDialog(null,"ErrorDB-02:"+e); return; } } }
//java2101.java
AHORA ESTA ES LA CLASE EN LA QUE PRETENDO USAR LA ANTERIOR.
/* * fraPrincipal.java * * Created on 4 de julio de 2007, 02:52 PM */
package TimeControl; import java.util.Calendar; import javax.swing.*; import java.lang.*; import javax.swing.Timer; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; //***************************** import java.sql.*;
/** * * @author JaorSoftware */ public class fraPrincipal extends javax.swing.JFrame { // Variable to Count the Time int intSecondsCount=0; int intMinutesCount=0; int intHoursCount=0; boolean boolResult;
//Declare Variable to control DB // AQUI EL CONSTRUCTOR TRABAJA BIEN. java2101 connDB = new java2101();
//***************************************** // ***************************************** // AQUI ESTOY TRATANDO DE USAR EL METODO DECLARADO // EN LA CLASE Y ES DONDE ME DA EL ERROR connDB.SubCloseConnection();
//
SE QUE DEBE SER ALGO SENCILLO PERO NO TENGO EL CONCEPTO.
GRACIAS DE ANTEMANO
JAOR |
| | Volver arriba | |  | wip
Registrado: 13 Sep 2005 Mensajes: 51
| Publicado: 10/07/2007 1:16 pm | | | Título: Re: error 32 <identifier> expected |
| Hola, pues eh compilado tu código y no me ha dado errores, talvez lo que pase es que estes usando esta instrucción
| Código: | connDB.SubCloseConnection(); |
fuera de alguna función, ya sea tu main o cualquier otra, ya que es lo que haces, es un error, pues las instrucciones van dentro de las funciones, fuera de las funciones, sòlo debe de ir la declaraciòn de variables _________________
El conocimiento libre es una cuestión ética, de principios, y no sólo una batalla por la comodidad, la gratuidad o la legalidad |
| | Volver arriba | |  | | |
| No puede crear mensajes No puede responder temas No puede editar sus mensajes No puede borrar sus mensajes No puede votar en encuestas
|
|
| |