Retroceder   Foros del Web > Programación para sitios web > Java y JSP > JSP/Servlets

Respuesta
 
Herramientas Desplegado
Antiguo 17-dic-2004, 14:19   #1 (permalink)
saymon_set está en el buen camino
 
Fecha de Ingreso: septiembre-2003
Mensajes: 37
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>
saymon_set está desconectado   Responder Citando
Respuesta

No hay votos aún.


Herramientas
Desplegado

Normas de Publicación
No puedes crear nuevos temas
No puedes responder temas
No puedes subir archivos adjuntos
No puedes editar tus mensajes

BB code is Activado
Caritas están Activado
[IMG] está Activado
Código HTML está Desactivado


La Zona horaria es GMT -6. Ahora son las 19:27.


Message Board Statistics

LinkBacks Enabled by vBSEO 3.1.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93