Home Answers Viewqa Java-Beginners database problem

 
 


surender mohan
database problem
1 Answer(s)      2 years ago
Posted in : Java Beginners

I did connect my jsp page to database and it showed the result on another jsp page but i want to show the data of that field on which i click to mouse from the jsp page where all the data field has been showed. Please suggest me what will the code of it.

View Answers

May 16, 2011 at 5:39 PM


1)ajax.jsp:

<%@page import="java.sql.*"%>
<html>
<head>
<script type="text/javascript">
function showData(id){ 

xmlHttp=GetXmlHttpObject()
var url="getdata.jsp";
url=url+"?id="+id;
xmlHttp.onreadystatechange=stateChanged 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
function stateChanged(){ 
if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
    var showdata = xmlHttp.responseText; 
    var strar = showdata.split(":");
    document.getElementById("name").value= strar[1];
    document.getElementById("address").value= strar[2];
    document.getElementById("contactNo").value= strar[3];
    document.getElementById("email").value= strar[4];
    } 
}
function GetXmlHttpObject(){
var xmlHttp=null;
try {
  xmlHttp=new XMLHttpRequest();
 }
catch (e) {
 try  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}


</script>
</head>
<body>
<form name="employee" >
<br><br>
<table >
<div id="mydiv"></div>
<tr><td><b>Select:</b></td><td><select name="id" onchange="showData(this.value);">
<option value="-1">--Select--</option>
   <%
   Class.forName("com.mysql.jdbc.Driver");
           Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
           Statement st=con.createStatement();
           ResultSet rs=st.executeQuery("select * from employee ");
           while(rs.next()){
               %>
               <option value="<%=rs.getInt("id")%>"><%=rs.getInt("id")%></option>
               <%
           }
               %>
               </select></td></tr>

<tr><td><b>Name:</b></td><td><input  type="text" name="name" id="name" ></td></tr>
<tr><td ><b>Address:</b></td><td>
<input  type="text" name="address" id="address" ></td></tr>
<tr><td><b>ContactNo:</b></td><td>
<input  type="text" name="contactNo" id="contactNo" ></td></tr>
<tr><td><b>Email:</b></td><td>
<input  type="text" name="email" id="email" ></td></tr>
</table>
</form>    
<table border="0" width="100%" align="center">
<br>
<br>
</table>
</body>
</html>

2)getdata.jsp:

<%@ page import="java.sql.*" %> 
<%
int id = Integer.parseInt(request.getParameter("id"));
String data ="";
try{
           Class.forName("com.mysql.jdbc.Driver");
           Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
           Statement st=con.createStatement();
           ResultSet rs=st.executeQuery("select * from employee where id="+id+"");
while(rs.next())
{
data =":"+rs.getString("name")+":"+rs.getString("address") + ":" + Integer.parseInt(rs.getString("contactNo"))+":"+rs.getString("email");
}
out.println(data);
System.out.println(data);
}
catch (Exception e) {
System.out.println(e);
}
%>









Related Pages:
database problem
database problem  I did connect my jsp page to database and it showed the result on another jsp page but i want to show the data of that field on which i click to mouse from the jsp page where all the data field has been showed
database problem
database problem  I did connect my jsp page to database and it showed the result on another jsp page but i want to show the data of that field on which i click to mouse from the jsp page where all the data field has been showed
problem in database
problem in database   thanks for web site. I want change this code to insert data into PostgreSql database using jsp,servlets. but i getting...){ out.println("Couldn't load database driver: " + e.getMessage()); } catch
Database fetching problem
Database fetching problem  I have multiple database table and want to get all records in one object how can i do this.Pls guide
database connectivity problem
database connectivity problem  what if client dont have database with them then what is other way to run successfully our programm   Please visit the following link: http://www.roseindia.net/jdbc
Oracle 9i database problem
Oracle 9i database problem  Hi Somebody has given the solution but i.............,send reply immediately. I have a problem in Oracle9i .I have installed... what i created .But after closing the SQL+ ,the problem started.When i again opened
Database problem - WebSevices
simple database connectivity code. if you have any problem then send me detail...Database problem  Hello, How i connect my database file& tables to Zend library file. In which library file i should change that code
database problem - JDBC
database problem  I installed Oracle 8.05 on Redhat 6.1 linux. If i fire up SQl plus seesion from the localhost, i can login succsfully as any user, If i go to a win98 or NT machine, I will get the following error after trying
Problem in accessing data from Database
Problem in accessing data from Database  hi..... i'm making a project on servlet and jsp with ms access 2007 at the backend. One field in my database... someone plz help me out with this problem
Problem in Jsp and database - Development process
Problem in Jsp and database  Hi, How can I reterive values from database and display them in teextboxes so that when the user select the UPDATE... to the database itself . Thanks in advance.  Hi Friend, You can use
problem in setting the values from database
problem in setting the values from database  hello friends, can anyone help me?? I am facing this problem for past one week. I could't set the values from database. here is the code: private JTextField getJTextField1
Problem in uploading image to to mysql database
Problem in uploading image to to mysql database  Hi, need some help... be save in the database. and the image will also save in the desired folder. i have no problem in saving the image in the folder, my problem is it can't save
Problem in uploading image to to mysql database
Problem in uploading image to to mysql database  Hi, need some help... be save in the database. and the image will also save in the desired folder. i have no problem in saving the image in the folder, my problem is it can't save
Database
to mention the problem. Specify your query
getting problem in storing & retrieving value in database
getting problem in storing & retrieving value in database  Hello everyone i am doing a project where my back end is ms access & i want to store value like 5353250214 so if i store it as long int in access it wont take it &
problem on php
problem on php   l have five tables and build them as forms and link between them php and database and i want to build query between them plz help me soon   PHP MySQL Tutorials
problem in selecting second arraylist from mysql database
problem in selecting second arraylist from mysql database  Hi... in mysql database. In the below program , i have hard-coded that second list, but i want second list to be dynamic from database. Please, help me out. Thank
Problem with JRadioButton and Access Database - Java Beginners
Problem with JRadioButton and Access Database  Hello sir ,Here I have... in Access Databse, I want to store course type in to database and also other fields...(); JOptionPane.showMessageDialog(p1,"Data is successfully inserted into database."); con.close
Problem in jsp.
Problem in jsp.  hello friends, I have a problem in jsp.I want... name also is given by the user.My database is in mysql.Plsssss help me... Thanks... inserted into database."); } catch(Exception e
Problem in jsp.
Problem in jsp.  hello friends, I have a problem in jsp.I want... name also is given by the user.My database is in mysql.Plsssss help me... Thanks... inserted into database."); } catch(Exception e
Problem in jsp.
Problem in jsp.  hello friends, I have a problem in jsp.I want... name also is given by the user.My database is in mysql.Plsssss help me... Thanks... inserted into database."); } catch(Exception e
Jsp problem
Jsp problem  Hello friends.I want to share my jsp problem.I want to show all of my database(mysql) tables except two(user,manufacturer) in a jsp page.plssss help me
uploading problem
about file into database lib. i use navicat Mysql ... i use this code... <...(); } } } } %> my problem...: firstly.... then problem solved... bt real problem is when i upload files fusing mozilla
java Problem
java Problem  I want to create a binary tree for displaying members in Downline. i am creating a site for MLM(Multi-Level MArketing). tree must be dynamically populated from database. is there any help for me. Thanks in advance
jdbc problem
jdbc problem   hi my name is mohit...i am making a project in java... and password with the already entered username and password in the database... in the database....pls help me guys...i am new to java...pls help me learn... thanks
Servlet problem
problem from last three month and now i hope rose india developers.... It is quite strange when i point webpage to other jsp page having same database connectivity code it works but problem is with servlet page. My servlet code
report problem
report problem  I have made a project that displays charts using jfreechart library from the student marks stored in a database. what all can i write in its report.Please if you can provide me hint or some link regarding
query problem
that displays the employee names from the database table who are Marketing Managers
Facing Problem to insert Multiple Array values in database - JSP-Servlet
facing the problem while inserting the data in database. iam using the MsAccess Database My Database structure is Like iam using tow tabel ,CustomerDetails...Facing Problem to insert Multiple Array values in database  Hai
problem in servlet program
problem in servlet program  Dear Sir, I have a problem to insert the Blob type data like as video file, audio file in the database using Servlet and html code
Problem with Double type Value in Access Database - Java Beginners
Problem with Double type Value in Access Database  Hello sir I have... Mobile Number with MS access Database,plz Help Me Sir.   Hi Friend...+")"); JOptionPane.showMessageDialog(null,"Data is successfully inserted into database."); ResultSet rs
problem from registering a data in database with servlet - JSP-Servlet
problem from registering a data in database with servlet  Hi Rose, i created a servlet to validates ten user details in the database, if present... the user's details and submit into database. but it'll first insert the details
Problem insert data into database using servlet n javabean - Java Beginners
Problem insert data into database using servlet n javabean  I created a servlet for registration proses I got a problem compiling my servlet.. (incompatible type: int and required: java.lang.ResultSet) can anyone help me
Database with dotnet
Database with dotnet  The main problem to connect the database with any dotnet platform website is that the database we create is not portable. we have to design again our database if we run db website from another machine. So
java programming problem - JDBC
java programming problem  Hi, Request you to provide the source code in Java for the following programming problem : upload .csv file data into oracle database. please send the solution to raichallp@yahoo.in
jasper problem - XML
jasper problem  URGENT PROBLEM!!!!!!!!!!!!! how can we use a hash table in jasper reports to generate reports without using database connection directly but access data from the hash table what we needed for creation
jdbc and swing problem in netbeans
jdbc and swing problem in netbeans  i reteived the table from database in a jdbc program. next i want to do is place the table as it is in a jpanel.. i am using netbeans IDE can u tel me how to do that one?? urgent
jdbc and swing problem in netbeans
jdbc and swing problem in netbeans  i reteived the table from database in a jdbc program. next i want to do is place the table as it is in a jpanel.. i am using netbeans IDE can u tel me how to do that one?? urgent
Problem with picture - Java Beginners
Problem with picture   Hi, I Develope a School Automated System that takes a details from the user interface and deposited into the database... to submit the picture to the database (MSSQL), after submitting a refrence
Problem with picture - Java Beginners
Problem with picture   Hi, I Develope a School Automated System that takes a details from the user interface and deposited into the database... to submit the picture to the database (MSSQL), after submitting a refrence
jsp problem - JSP-Servlet
jsp problem  here is a code for Retrieving image from mysql database... i do?? when the image retrieve from the database i want to set its size to how can and if one can set size of photo before store into database then also tell
jsp problem - JSP-Servlet
jsp problem  here is a code for Retrieving image from mysql database... i do?? when the image retrieve from the database i want to set its size to how can and if one can set size of photo before store into database then also tell
Database - WebSevices
Database   Hello, Any one know the detail Database Structure for creating new job site with features.   Hi friend, Plz give full details and requirement to solve the problem and visit to : http
Database Connectivity
Database Connectivity  I tried to establish database connection with sqlserver2008 through GlassFish server. When I set the path of sqljdbc.jar(E... for:com.ddtek.jdbcx.sqlserver.SQLServerDataSource" how to resolve this problem
Javascript problem - WebSevices
before submitting the form with the condition of being empty. PROBLEM:-->... the database value and if the user wants he can edit. Thanks..  Hi friend, Please specify the problem : You want to return back same page
iterator display problem - Struts
iterator display problem   in action class i store database data in arrraylist but after success how can i display those data in jsp page using... friend, Code to help in solving the problem : Iterator Tag
Multi-Date Handling Problem
Multi-Date Handling Problem  In our project we are using Oracle 10g as our data base, the problem is that we are picking In-date & Out-date from... Database, but we cant free that from our data base if the given Out-date
java programming problem - JDBC
problem to the following mail id : Problem : upload excel file data into oracle database using java / j2ee. mail id : raichallp@yahoo.co.in... it into the MySQL database. It contains three files :1) ODBCConnection.jsp (reads data
JDBC related Problem - JDBC
the other the access from the database is successful the problem is only arising... connectivity code ...... my problem is... that even after the successful compilation and execution .... the update process of the database is not performed
Servlet problem - JDBC
SQL 2000 database and I have developed a servlet that accepts input from user but however. It gives problem sometimes while at others it works perfectly. I m

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.