//Statement stmt = conexion.createStatement();
Por que?
Código:
package conexion; import java.sql.*; public class GenericaDb { public String driver,url,ip,bd,usr,pass; public Connection conexion; public static void main(String[] args){ GenericaDb pnbd = new GenericaDb("VISTAESCRITORIO:5000","Pruebas","sa",""); Connection conexion = pnbd.getConexion(); //Statement stmt = conexion.createStatement(); } public GenericaDb(String ip, String bd, String usr, String pass) { driver="com.sybase.jdbc3.jdbc.SybDriver"; this.bd = bd; this.usr = usr; this.pass = pass; url = new String("jdbc:sybase:Tds:"+ip+"/"+bd); try { Class.forName(driver).newInstance(); conexion=DriverManager.getConnection(url,usr,pass); System.out.println("Conexion a Base de Datos "+bd+" Ok"); } catch (Exception exc) { System.out.println("Error al tratar de abrir la base de Datos"+bd+" : "+exc); } } public Connection getConexion() { return conexion; } public Connection CerrarConexion() throws SQLException{ conexion.close(); conexion = null; return conexion; } } //fin de la clase