Foros del Web » Programación para mayores de 30 ;) » Java »

Me conecto via jdbc con oracle .. y derrepente ...

Estas en el tema de Me conecto via jdbc con oracle .. y derrepente ... en el foro de Java en Foros del Web. Me conecto via jdbc con oracle .. y derrepente ... perdio la conexion causa raíz java.sql.SQLException: Imposible establecer la conexion on BD pkfactura.books.connect(books.java:35) org.apache.jsp.index_jsp._jspService(index_jsp.jav a:80) ...
  #1 (permalink)  
Antiguo 17/12/2004, 15:19
 
Fecha de Ingreso: septiembre-2003
Mensajes: 37
Antigüedad: 20 años, 7 meses
Puntos: 1
Me conecto via jdbc con oracle .. y derrepente ...

Me conecto via jdbc con oracle .. y derrepente ... perdio la conexion
causa raíz

java.sql.SQLException: Imposible establecer la conexion on BD
pkfactura.books.connect(books.java:35)
org.apache.jsp.index_jsp._jspService(index_jsp.jav a:80)

etc etc..

, estuves varias veces haciendo pruebas y en una de esas ya no se puede conectar al servidor .. , porque ?? que pasaria=??


la clase es
public class books {
String error;
Connection conn;
/** Creates a new instance of books */
public books() {
}
public void connect () throws ClassNotFoundException, SQLException,Exception{
try {
// Class.forName("org.gjt.mm.mysql.Driver").newInstan ce();
// conn = DriverManager.getConnection("jdbc:mysql://localhost/prueba","root","root");
Class.forName("oracle.jdbc.driver.OracleDriver").n ewInstance();
conn = DriverManager.getConnection("jdbc:oracle:thin:@PLU TON:1521:ORCL9I","DINAMICAS","DINAMICAS");

}
catch(ClassNotFoundException e){
error="No se puede locxalizar el controlador.";
throw new ClassNotFoundException(error);
}
catch(SQLException e){
error="Imposible establecer la conexion on BD";
throw new SQLException(error);
}
catch(Exception e){
error="Hubo un error inseperado.";
throw new Exception(error);

}
}

public void disconnect () throws SQLException{
try{
if (conn != null){
conn.close();
}
}
catch(SQLException e){
error = "Impòsible cerrar la conexion";
throw new SQLException(error);
}
}
public ResultSet viewbooks()throws SQLException, Exception {
ResultSet rs=null;
books d = new books();
try{

//String sql="SELECT CONCEPTO FROM FACTURAS_EMITIDAS";
String sql=d.GenerarSQL();
/// String sql="select * from book;";
Statement stmt= conn.createStatement();
rs=stmt.executeQuery(sql);
}
catch(SQLException e){
error="No se puede ejecutar la consulta";
}
catch(Exception e){
error="Hubo un error";
throw new Exception(error);
}
return rs;
}

public void addbook(int id, String title, int price,int cid)throws SQLException,Exception{
if (conn != null ){
try{
PreparedStatement updatebook;
updatebook=conn.prepareStatement("insert into FACTURAS_EMITIDAS values(?,?,?,?)");
updatebook.setInt(1,id);
updatebook.setString(2,title);
updatebook.setInt(3,price);
updatebook.setInt(4,cid);
updatebook.execute();


}catch(SQLException e){
error="Hubo un error SQL";
throw new SQLException(error);
}
}else{
error="se perdio lña conexion a la bd.";
throw new Exception(error);
}

}
public void removebook (String[] pkeys)throws SQLException, Exception{
if (conn != null ){
try{
PreparedStatement ps= conn.prepareStatement("delete from FACTURAS_EMITIDAS where id=?");
for(int i=0; i<pkeys.length;i++){
ps.setInt(1, Integer.parseInt(pkeys[i]));
ps.execute();
}
}catch(SQLException e){
error="Hubo un sql exceptiln";
throw new SQLException(error);
}catch(Exception e){
error="se produjo un error";
throw new Exception(error);
}
}else{
error="se ha perdido la conexion con la bd.";
throw new Exception(error);
}

}

public String GenerarSQL()throws Exception{
try{
String Sql ="";
String StrFiltro ="";
StrFiltro = null;
//If (CheckFecha.Value = 1) Then StrFiltro = " AND F.FECHA_FACTURA =TO_DATE('" & Format(Fecha.Text, "DD/MM/YYYY") & "','DD/MM/YYYY')"
//If (CheckInstitucion.Value = 1) Then StrFiltro = StrFiltro & " AND F.INSTITUCION_ID ='" & Filtrar_Cadena(FiltroInstitucion.Text, "-") & "'"
//If (CheckStatus.Value = 1) Then StrFiltro = StrFiltro & " AND F.STATUS ='" & Filtrar_Cadena(FiltroStatus.Text, "-") & "'"
//Sql="SELECT CONCEPTO FROM FACTURAS_EMITIDAS";

Sql = "select f.contrato,f.concepto,f.nro,f.fecha_factura,f.dola res,t.cambio ,";
Sql=Sql + "i.nombre,f.tipocambio_id,f.institucion_id,f.codig ocontable,f.status,f.fecha_pago,f.anio_canc,f.fact urasemi_id from ";
Sql = Sql + " facturas_emitidas f,institucion i,tipo_cambio t where t.tipocambio_id=f.tipocambio_id and i.institucion_id=f.institucion_id ";
//Sql = Sql & StrFiltro
return Sql;
}
catch(Exception e){
error="Ocurrio una excepcion en GenerarSql:" + e;
throw new Exception (error);
}
}

}

// AQUI ESTA DONDE LA LLAMO

<%@ page language="java" import="java.sql.*,java.io.*,java.util.*,pkfactura .*"%>
<jsp:useBean id="book" class="pkfactura.books" />
<html>
<body>
<h1> wrox press ltd </h1>
<h2>list books </h2>
<a href="newbook.jsp"><b>Añada mas libros</b></a>
<form action="delete.jsp" mkethod="post">
<table border=1>
<tr>
<td><b>Eliminar</b></td>
<td><b>Contrato</b></td>
<td><b>Concepto</b></td>
<td><b>Nro</b></td>
<td><b>Fecha Factura</b></td>
<td><b>Dolares</b></td>
<td><b>Tipo Cambio</b></td>
<td><b>Bolivares</b></td>
<td><b>Institución</b></td>
<td><b>Codigo Contable</b></td>
<td><b>Status</b></td>
<td><b>Fecha Pago</b></td>
<td><b>Año de Pago</b></td>
</tr>
<%
book.connect();
ResultSet rs= book.viewbooks();
while (rs.next()){
%>
<tr>
<td><input type ="checkbox" name="pkey" value="<%=rs.getString("institucion_id") %>" /> </td>
<td><%=rs.getString("contrato")%></td>
<td><%= rs.getString("concepto")%></td>
<td><%= rs.getString("nro")%></td>
<td><%= rs.getString("fecha_factura")%></td>
<td><%= rs.getString("dolares")%></td>
<td><%= rs.getString("Cambio")%></td>
<td><%= rs.getString("dolares") %></td>
<td><%= rs.getString("nombre") %></td>
<input type="hidden" name="tipocambio_id" value=<%= rs.getString("tipocambio_id") %>>
<input type="hidden" name="institucion_id" value=<%= rs.getString("institucion_id") %>>
<td><%= rs.getString("codigocontable") %></td>
<td><%= rs.getString("status") %></td>
<td><%= rs.getString("fecha_pago") %></td>
<td><%= rs.getString("anio_canc") %></td>
</tr>
<% }%>
</table>


<table border=0>
<tr>
<tr><td><b>Contrato</b></td><td><input type=text name="contrato"</td> </tr>
<tr><td><b>Concepto</b></td><td><input type=text name="concepto"</td> </tr>
<tr><td><b>Nro</b></td><td><input type=text name="nro"</td> </tr>
<tr><td><b>Fecha Factura</b></td><td><input type=text name="fecha"</td> </tr>
<tr><td><b>Dolares</b></td><td><input type=text name="dolares"</td> </tr>
<tr><td><b>Tipo Cambio</b></td><td><input type=text name="tipocambio"</td> </tr>
<tr><td><b>Institución</b></td><td><input type=text name="institucion"</td> </tr>
<tr><td><b>Codigo Contable</b></td><td><input type=text name="codigocontable"</td> </tr>
<tr><td><b>Status</b></td><td><input type=text name="status"</td> </tr>
<tr><td><b>Fecha Pago</b></td><td><input type=text name="fechapago"</td> </tr>
<tr><td><b>Año de Pago</b></td><td><input type=text name="anio_canc"</td></tr>
</table>



fechapago
anio_canc

<input type="submit" value="elimine todos los libros marcados.">
</form>
<% book.disconnect(); %>
<a href="sumar">volver</a>
</body>
</html>
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 06:18.