Retrieve selected Data From a Table
Hello, I am searching for the program which can help me to retrieve the data from the table with the help of java programming. I have tried it, but I am getting error while doing it, if anyone is having some or the other information while working on it or if you are having any code to help me then please reply me about it.
Re: Retrieve selected Data From a Table
Hey, same problem here, while retrieving selected data from the table I was also getting problem. I have code below for it:
<display: table id ="Loan" name ="$ () contexteSession.listePret" pagesize ="20" requestURI ="choixpret.do" summary ="Ready list">
Code:
<display:column>
<html: radio property ="pretSelected" value ="$ () pret.numero"/>
</ display: column>
<display: column property ="numero" title ="Number />
<display: column property ="type" title ="Type"/>
<display: column property ="state" title ="State />
<display: column property ="nominal" title ="Nominal"/>
</ display: table>
Code:
List <Pret> listePret = ListePretService.recupererListePret(context,
user fctRecherche, choixClientForm);
ContexteSessionUtil.GetContexteSession(request.getSession()).setListePret(listePret);
If anyone is having solution on it then please help me.
Re: Retrieve selected Data From a Table
Hello, I am making use of the code below for retrieving selected data from a list:
Code:
<% Int idx = 0;%>
<display: table id ="Loan" name ="$ () contexteSession.listePret" pagesize ="20" requestURI ="choixpret.do" summary ="Ready list">
<display:column>
<html: radio property ="pretSelected" value ="<% = i ++%>"/>
</ display: column>
Re: Retrieve selected Data From a Table
To Retrieve selected Data From a Table you need to make use of the jdbc code below:
Code:
import java.sql.*;
public class Testdemo
{
public static void main(String[] args)
{
String url = " jdbc:odbc:test ";
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:test"; "", "");
Statement statement = con.createStatement();
ResultSet rs = statement.execute("select ename,job from emp");
while(rs.next())
{
System.out.println(rs.getString(1));
System.out.println(rs.getString(2));
}
catch( Exception e )
{
e.printStackTrace();
}
}
}
Re: Retrieve selected Data From a Table
If you are making use of the java the you need to make use of the execute() method. This execute() method of the Statement object can help you to get the data from a table. For creating this code you need to create first JDBC connection with the database and then need to get the all of the records from the table or records which you want. For that use of the ResultSet object is done. So, that afterword all the content from the ResultSet is printed to the console.
Re: Retrieve selected Data From a Table
If you want to select the single row from the table then you need to make use of the following code:
Code:
String rollno = rollNumber.getText();
try
{
PreparedStatement pstmt;
boolean got = false;
pstmt = theConn.prepareStatement("select custName, CustAddr from tCust where rollNum = ?");
pstmt.setString(1, rollno);
ResultSet rs;
rs = pstmt.executeQuery();
got = rs.next();
if (got)
System.out.println(rs.getString(1));
else
System.out.println("Customer " + rollno + " not got!");
pstmt.close();
}
catch (Exception e)
{
e.printStackTrace();
}