473,473 Members | 1,833 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

username and mysql

1 New Member
i am pretty new to java and have an application, i need it to be able to get values entered in a java form (username and password) and compare it to data in the mysql table, if it matches then let the user in, if not then generate a user error message..... can anybody help me with this???

the names of the textfield is username_textField, and password field is passwordField.
Mar 17 '07 #1
5 1900
hirak1984
316 Contributor
post the code you have tried.we will fix the code if there is error.

If you didnt start yet,grab a HEAD FIRST WITH JAVA book and start reading it.You will be able to make the application yourself.
Good Luck
i am pretty new to java and have an application, i need it to be able to get values entered in a java form (username and password) and compare it to data in the mysql table, if it matches then let the user in, if not then generate a user error message..... can anybody help me with this???

the names of the textfield is username_textField, and password field is passwordField.
Mar 17 '07 #2
r035198x
13,262 MVP
i am pretty new to java and have an application, i need it to be able to get values entered in a java form (username and password) and compare it to data in the mysql table, if it matches then let the user in, if not then generate a user error message..... can anybody help me with this???

the names of the textfield is username_textField, and password field is passwordField.
Can you connect to the database using jdbc? If you don't know how to do that you might want to have a look at a jdbc tutorial first.
Mar 17 '07 #3
hirak1984
316 Contributor
I dont think connecting to database will be wise at this satge.

first make the page.see if that is working well ,check with hardcoded values.
then go for backend works.
Can you connect to the database using jdbc? If you don't know how to do that you might want to have a look at a jdbc tutorial first.
Mar 17 '07 #4
ramusunny
4 New Member
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.sql.*;
public class LoginServlet extends HttpServlet
{ Connection con;
Statement st;
ResultSet rs;
public void init()
{
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
con=DriverManager.getConnection("jdbc:oracle:thin: @localhost:1521:oracleex","scott","tiger");
st=con.createStatement();
}
catch (Exception e)
{
e.printStackTrace();
}
}
public void doGet(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException
{
try{
PrintWriter out=res.getWriter();
String H_username=req.getParameter("username");
String H_password=req.getParameter("Password");
st=con.createStatement();
rs=st.executeQuery("select * from THospital_login where H_username='"+H_username+"' and H_password='"+H_password+"'");
out.print("the given values are:"+H_username+H_password);
if(rs.next())
{
out.print("<center>");
out.print("<B>validuser<B>");
out.print("</center>");

}
else
{
out.print("<center>");
out.print("invaliduser");
out.print("</center>");
}
}
catch(Exception e1)
{
e1.printStackTrace();
}
}

public void destroy(){
try
{
System.out.println("destroy the connection");;
}
catch (Exception e2)
{
e2.printStackTrace();
}
}
}
Mar 17 '07 #5
ramusunny
4 New Member
this above program is suitble to what ever seiing the table just u can create the table..n..enjoyyyyyyyyyy..thats it..my e-mail address is <email:Removed>...do u have any doubts plz ask..i can improve my skills .......thanku .......bye
Mar 17 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Phil W | last post by:
Hi, I'm a bit of a newbie to PHP and mySQL. I'm trying to get things running on my W2K machine. I'm having a problem using the mysql_connect() function (although the problem's probably rooted in...
7
by: Candice | last post by:
Please somebody help! I've deleted my admin username and password which was initially set at test. Now I can't log into my website as the administrator. How do I put Username and Password back so...
3
by: red | last post by:
I know this is probably a faq but it is hard to search for this exact problem. When I put this on a php page: <? $link = mysql_connect("localhost", "cardini", "password") or die("Could not...
0
by: yurps | last post by:
Hello, I installed both, 1st mysql 4.1.7 but heard there was a change with password hashing so now got 4.0.9 Basically when I choose a page with php_info() I can load it fine, but when I call a...
1
by: Anthony Davis | last post by:
Hello All, I have been using the MySQL control center and had my usernames and passwords for the MySQL server stored in the control center. I recently lost everything on my PC including the...
0
by: cmk128 | last post by:
Hi My mysql 4.1 has a username max char limit of 16, how to enlarge it? thanks from Peter (cmk128@hotmail.com)
1
by: vinokarthi | last post by:
Hi, I couldn't connect mysql & php.I tried with many query,but no use. If I run php,the page is blank. I think I have problem with to create user & password in mysql. Plz help to connect...
2
by: poolboi | last post by:
hey guys i got the code below to authenticate users for database #!perl\bin\perl use strict; use warnings; use DBI();
3
daJunkCollector
by: daJunkCollector | last post by:
Hey. I am using mysql, php, and javascript (jquery). I have a nice form setup where the username field validates AJAX-style against my database... this technique allows for the user to see if his...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.