how to display data from mysql table in text box using jsp??

how to display data from mysql table in text box using jsp??

<p>hi, i have a written a code to display data from a mysql table into txtboxes..But i am getting the following error...</p>

<p>An error occurred at line: 113 in the jsp file: /Cat1.jsp
The local variable v_RGPC may not have been initialized
110:   </tr>
111:   <tr>
112:     <th scope="row">Reference GPC</th>
113:     <td><input type="text" name="txtRGPC" value=&lt;%out.println(v_RGPC);%>/>
114:       </td>
115:     <th>Numint</th>
116:     <td><input type="text" name="txtNI" value=&lt;%out.println(v_NI);%>/></td></p>

<p>here is my source code</p>

<p>&lt;%@ page import="java.sql.*" %> 
&lt;%@ page import="*" %> </p>

<link rel="stylesheet" type="text/css" href="cintel.css">

try {</p>

<p>String connectionURL = "jdbc:mysql://"; 
Connection connection = null;
ResultSet rs=null;
Statement statement=null;
// Load JBBC driver "com.mysql.jdbc.Driver". 
connection = DriverManager.getConnection(connectionURL, "root", "root");
int updateQuery = 0;
String QueryString = "SELECT * FROM code<em>ot WHERE code</em>codeot=12";
//Connection con=null;
int v_TS     = 1;
String v_RGPC; <br />
String v_CETR; <br />
String v_DR; <br />
String v_CS; <br />
String v_CP; <br />
String v_TOp; <br />
String v_Ddeb; <br />
String v_COEIE; <br />
String v_CAtt; <br />
String v_IDAtt; <br />
String v_NI; <br />
String v_UP; <br />
String v_Centre; <br />
String v_CodeO; <br />
String v_CGest; <br />
String v_TEq; <br />
String v_Dfin; <br />
String v_Zone; <br />
String v_CTrx; <br />
String v_NChan; <br />
String v_Code; <br />
String v_QtL; <br />
String v_Large; <br />
String v_Haut; <br />
String v_Des; <br />
String v_Maj; <br />
String v_Qt; <br />
String v_Cout; <br />
String v_Tot;          </p>

<p>// check weather connection is established or not by isClosed() method 
statement = connection.createStatement();</p>

<pre class="prettyprint">      // sql query to retrieve values from the secified table.
      rs = statement.executeQuery(QueryString);

v_RGPC   = "rs.getString(2)";
v_CETR   = rs.getString(2);
v_DR     = rs.getString(2);
v_CS     = rs.getString(2);
v_CP     = rs.getString(2);
v_TOp    = rs.getString(2);
v_Ddeb   = rs.getString(2);
v_COEIE  = rs.getString(2);
v_CAtt   = rs.getString(2);
v_IDAtt  = rs.getString(2);
v_NI     = rs.getString(2);
v_UP     = rs.getString(2);
v_Centre = rs.getString(2);
v_CodeO  = rs.getString(2);
v_CGest  = rs.getString(2);
v_TEq    = rs.getString(2);
v_Dfin   = rs.getString(2);
v_Zone   = rs.getString(2);
v_CTrx   = rs.getString(2);
v_NChan  = rs.getString(2);
v_Code   = rs.getString(2);
v_QtL    = rs.getString(2);
v_Large  = rs.getString(2);
v_Haut   = rs.getString(2);
v_Des    = rs.getString(2);
v_Maj    = rs.getString(2);
v_Qt     = rs.getString(2);
v_Cout   = rs.getString(2);
v_Tot    = rs.getString(2);</p>



<form method="post" action="insertdata.jsp">
<h2>Saisie Attachement</h2>
<table width="1300">
    <th colspan="2" scope="col">Attachement Sur l'OT/L'OEIE: ATT_GDP_01</th>
    <th colspan="3" scope="col">Etat1</th>
    <th colspan="3" scope="col">Flux</th>
    <th width="216" scope="row">Type de Situation</th>
    <td><input type="text" name="txtTS"/></td>
    <th scope="row">Reference GPC</th>
    <td><input type="text" name="txtRGPC" value=<%out.println(v_RGPC);%>/>
    <td><input type="text" name="txtNI" value=<%out.println(v_NI);%>/></td>
    <th scope="row">Code ETR</th>
    <td><input type="text" name="txtCETR" value=<%out.println(v_CETR);%>/></td>
    <th>Unite de Production</th>
    <td><input type="text" name="txtUP" value=<%out.println(v_UP);%>/></td>
    <th scope="row">Domaine Reseau</th>
    <td><input type="text" name="txtDR" value=<%out.println(v_DR);%>/></td>
    <td><input type="text" name="txtCentre" value=<%out.println(v_Centre);%>/></td>
    <td><input type="text" name="txtZone" value=<%out.println(v_Zone);%>/></td>
    <th scope="row">Code Secteur</th>
    <td><input type="text" name="txtCS" value=<%out.println(v_CS);%>/></td>
    <th>Code OEIE</th>
    <td><input type="text" name="txtCodeO" value=<%out.println(v_CodeO);%>/></td>
    <th>Famille Cat de Tvx</th>
    <td><input type="text" name="txtCTrx" value=<%out.println(v_CTrx);%>/></td>
    <th>No Chantier</th>
    <td><input type="text" name="txtNChan" value=<%out.println(v_NChan);%>/></td>
    <th scope="row">Code Prometee</th>
    <td><input type="text" name="txtCP" value=<%out.println(v_CP);%>/></td>
    <th>Code de Ch de Gestion</th>
    <td><input type="text" name="txtCGest" value=<%out.println(v_CGest);%>/></td>
    <th scope="row">Type d'Operation</th>
    <td><input type="text" name="txtTOp" value=<%out.println(v_TOp);%>/></td>
    <th>Type d'Equipement</th>
    <td><input type="text" name="txtTEq" value=<%out.println(v_TEq);%>/></td>
    <th scope="row">Date de Debut</th>
    <td><input type="text" name="txtDdeb" value=<%out.println(v_Ddeb);%>/></td>
    <th>Date de Fin</th>
    <td><input type="text" name="txtDfin" value=<%out.println(v_Dfin);%>/></td>
    <th scope="row">Commentaire de l'OEIE</th>
    <td colspan="2"><input type="text" name="txtCOEIE" size="57" value=<%out.println(v_COEIE);%>/></td>
    <th scope="row">Commentaire de l'Attelem</th>
    <td colspan="2"><input type="text" name="txtCAtt" size="57" value=<%out.println(v_CAtt);%>/></td>
    <th scope="row">Indicateur du dernier Attelem</th>
    <td><input type="text" name="txtIDAtt" value=<%out.println(v_IDAtt);%>/></td>
  <table width="1300">
    <th colspan="8" scope="col">Saisie de Code de travaux et/ou materiels associes</th>

   <td><input type="text" name="txtCode"/></td>
   <td><input type="text" name="txtQtL"/></td>
   <td><input type="text" name="txtLarge"/></td>
   <td><input type="text" name="txtHaut"/></td>
     <td colspan="8" rowspan="2">Lignes ASP et Materiel</td>
  <table width="1300">
    <th colspan="10">Saisie de lignes des factures</th>
     <td colspan="10"> </td>
   <td><input type="text" name="txtDes"/></td>
   <td><input type="text" name="txtMaj"/></td>
   <td><input type="text" name="txtQt"/></td>
   <td><input type="text" name="txtCout"/></td>
   <td><input type="text" name="txtTot"/></td>
     <td colspan="10"> </td>
     <td colspan="3.9"><input type="submit" name="btnsub"></td>
     <td colspan="3.9"> </td>
     <td colspan="4"> </td>

catch (Exception ex) {
            out.println("Unable to connect to database." + ex);</p>

<pre class="prettyprint">        }


<p>Plz help me</p>

<p>Regards priya</p>
View Answers

Related Tutorials/Questions & Answers:
how to display data from mysql table in text box using jsp??
How to get data from DB in to Text box by using Jsp & Ajax
unable to display table data on JSP page that is coming from mysql and servlet.
unable to display table data on JSP page that is coming from mysql and servlet.
unable to display table data on JSP page that is coming from mysql and servlet.
how to display a table from database using servlet
how to fetch data from mysql database table and draw a bar chart on that data using in jsp
Display Blob(Image) from Mysql table using JSP
how to display image and text in single jsp page from the mysql database
how to display values from database into table using jsp
How to display data fom MySQL DataBase-table in to JSP file by submitting a value in combobox.
how to display the selected row from the data table in model panel ??
how to display webservice response in a text box
How to display data in jsp from dao using java beans?
reading data from a text box with the same name using servlets - JSP-Servlet
how to upload an image from a jsp page to a mysql database table using jsp
how to load a table of data from oracle, to a jsp page using hashmap.
Fetch the data from mysql and display it on php form
Populate a combo box using data from a database
Display current date in text box in JSP using javascript
how to create a text box using awt
display data from a table in Access Database in a HTML page
How to "Get data froom MySQL DB on giving a value in a tex-box in a JSP file."
How to use next and previous button(or href) for database table that is retrieved from MySQL DB using jsp,jstl,javascript
How to display all the Select values from the MySQL database table in where condition= In JSP?
MYSQL retrieve record from Data table
Data needs to be gathered in XML file from the database (MySql) using JSP
How to insert data into MySQL Table?
How to Display values from databse into table
retrieve the data to text fields from database on clicking the value of combo box
How to delete data from MySQL?
Dynamic retrieval od data from database and display it in the table at jsp
filter and display html table data using ajax - Ajax
JDBC Video tutorial - How to read Data from MySQL Database?
How to insert data from a combobox and textbox values into DB using JSP?
how to display the data from excel to webpage
how to display data in List Or grid or in table in Jsp
Retrieving data from data base using jsp combo box
How to retrieve data from database by using combo box value in jsp? - JSP-Servlet
Display Data from Database in JSP
how i conditional access the data from database using combo box. - JSP-Servlet
Displaying Mysql clob data using Servlet
how to display data from database in jsp
To dump 10lakh lines from a text file to a mysql table
To display suggestions in a text box - Ajax
how to retrieve text and images from mysql database and show on html page using jsp servlet
how can i store text box values as it is in database table
dynamic retrivel of data from mysql database in table format at jsp
Retrive the data from the table in data base using jdbc
Hi how to transfer table data from html page to excel sheet by using javascript .