AJAX Forums

Database access with Ajax

This is a discussion on Database access with Ajax within the AJAX Deployment forums, part of the Advanced Ajax category; Hi, I have this Code for Accessing Database. And Its Working Fine But the Problem is That I Want to Get Control When the Results Coming. This is The Code\\ ...

Go Back   AJAX Forums > Advanced Ajax > AJAX Deployment

AJAX Made Easy


AJAX Deployment Discuss on AJAX Deployment

Reply

 

LinkBack Thread Tools Display Modes
Old 05-26-2009, 03:48 PM   #1 (permalink)
Junior Member
 
Join Date: May 2009
Posts: 1
Rep Power: 0
tarzan1234 is on a distinguished road
Database access with Ajax

Hi,
I have this Code for Accessing Database. And Its Working Fine But the Problem is That I Want to Get Control When the Results Coming.
This is The Code\\

Ajax Code
Quote:
function init(){
var val = dojo.byId("userV").value
if (val.length > 5) {
var url = "CheckUsername.jsp"
url = url + "?user=" + val
httpObject = getHTTPObject();
if (httpObject != null) {

httpObject.open("GET", url, true);
httpObject.send(null);
httpObject.onreadystatechange = display;

}
}
}
function display() {
if(httpObject.readyState == 4){
dojo.byId('content').innerHTML = httpObject.responseText;

}
}
function getHTTPObject(){
if (window.ActiveXObject) return new ActiveXObject("Microsoft.XMLHTTP");
else if (window.XMLHttpRequest) return new XMLHttpRequest();
else {
alert("Browser Dosent Support`s");
return null;
}
}

var httpObject = null;
and This is The CheckUsername.jsp Code

Quote:

String user = request.getParameter("user").toString();
String data ="";

Connection conn = null;
String url = "jdbc:mysql://localhost:3306/";
String dbName = "MyDBname";
String driver = "com.mysql.jdbc.Driver";
String userName = "My Username";
String password = "My Password";

int sumcount=0;
Statement st;
try {
Class.forName(driver).newInstance();

conn = DriverManager.getConnection(url+dbName,userName,pa ssword);
String query = "select username from login_info where username='"+user+"'";

st = conn.createStatement();
ResultSet rs = st.executeQuery(query);
if(rs.next())
{
%>
<table bgcolor="#ffffff" border="0">
<tr>
<td valign="middle" bgcolor="#ffffff">
&nbsp;&nbsp;<IMG src="Images/load-r.gif">&nbsp;&nbsp;
</td>
<td valign="top" bgcolor="#ffffff">
<font color="red" face="tahoma" size="1"> Not Allowed</font>
</td>
</tr>
</table>
<%
}
else
{
%>
<table bgcolor="#ffffff" border="0">
<tr>
<td valign="middle" bgcolor="#ffffff">
&nbsp;&nbsp;<IMG src="Images/load-g.gif">&nbsp;&nbsp;
</td>
<td valign="top" bgcolor="#ffffff">
<font color="green" face="tahoma" size="1">Its Allowed </font>
</td>
</tr>
</table>
<%
}

out.println(data);
}
catch (Exception e) {
e.printStackTrace();
}
I want To Chek Wether The Result Come from IF part Or Else Part.
Could Any One Help Me ???
Thanks In Advanced
tarzan1234 is offline   Reply With Quote
Sponsored Links
Reply

Bookmarks

Tags
database access with ajax


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
No More Excel! Access AJAX Spreadsheet Today! microbee AJAX Help 0 04-11-2009 01:09 PM
how can i access Client resources with javascript? meroo_abc JavaScript 1 06-15-2007 12:48 AM


All times are GMT -4. The time now is 03:08 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.3.0
Copyright ©2006 - 2009, AJAXwith.com