Create table in jdeveloped

Forum sobre a ferramenta Oracle JDeveloper, ADF, OAF, etc. (Não é destinado ao aprendeziado da Linguagem Java em geral)
Post Reply
francisco.angelo
Rank: Analista Júnior
Rank: Analista Júnior
Posts: 78
Joined: Wed, 16 Jan 2008 5:06 pm
Location: RJ
Francisco Angelo
///////////////////////////////

Hello, good morning,

I would like a help, I made a connection with the Oracle database and on this call I will consult the bank data by the name ...
the result , it's okay.

Only I want to skirt formatted inside a table as if it were a spreadsheet ..

and I do not get the code to get a table, I have the answer I want no longer formatted on a table.

The code I use is this:

Select all

<%@ page import="java.sql.*" %> 
 
<% 
String nome=request.getParameter("nome"); 
int flag=0; 
try{ 
Class.forName("oracle.jdbc.driver.OracleDriver"); 
Connection con = DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:XE","system","nino"); 
PreparedStatement stmt = con.prepareStatement("select * from aluno where nome=?"); 
stmt.setString(1,nome); 
ResultSet rs = stmt.executeQuery(); 
 
while(rs.next()){ 
 
out.print("<br>" + rs.getInt("cod")); 
out.print("<br>" + rs.getString("nome")    + rs.getString("endereco")); 
out.print("<br>" + rs.getString("endereco")); 
out.print("<br>" + rs.getString("tel")); 
flag=1; 
} 
 
if (flag==1){ 
out.print("<p>Nome Encontrado"); 
}else{ 
out.print("<p>Nome não Encontrado"); 
} 
 
 
} 
catch(Exception e){ 
 
} 
%> 
 
<br><a href="index.jsp">Voltar</a>
victorhugomuniz
Moderador
Moderador
Posts: 1396
Joined: Fri, 01 Feb 2008 2:06 pm
Location: Rio de Janeiro - RJ
Contact:
:D

Your problem is HTML buddy http://www.w3schools.com/html/html_tables.asp
in any case .. Try so oh ..

Select all

 
out.print("<table border=\"1\">");  
out.print("<tr>"); 
out.print("<th>Código</th>"); 
out.print("<th>Nome</th>"); 
out.print("<th>Endereço</th>"); 
out.print("<th>Telefone</th>"); 
out.print("</tr>"); 
while(rs.next()){  
out.print("<tr>"); 
out.print("<td>" + rs.getInt("cod") + "</td>");  
out.print("<td>" + rs.getString("nome") + "</td>");  
out.print("<td>" + rs.getString("endereco") + "</td>");  
out.print("<td>" + rs.getString("tel") + "</td>");  
out.print("</tr>"); 
flag=1;  
}  
out.print("</table>"); 
Mick
Rank: Programador Sênior
Rank: Programador Sênior
Posts: 69
Joined: Fri, 08 Feb 2008 11:20 am
Location: São Paulo - SP

Ahh ... but if I understood correctly ... what you want to do ... it's easier to create a view ... and then on the Data Control Pallet, drag your to View as ADF Table, for your JSP page ... and ready the table already comes ready !! ...
Mick
Rank: Programador Sênior
Rank: Programador Sênior
Posts: 69
Joined: Fri, 08 Feb 2008 11:20 am
Location: São Paulo - SP

victorhugomuniz
Moderador
Moderador
Posts: 1396
Joined: Fri, 01 Feb 2008 2:06 pm
Location: Rio de Janeiro - RJ
Contact:
:D

It's a friend ...
I think you should change all the course of your study / development
and follow what Mick is talking about, because you will have greater proutiveness using JDEV resources
Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 1 guest