Results 1 to 8 of 8
- 05-27-2010, 07:09 PM #1
Member
- Join Date
- May 2010
- Posts
- 7
- Rep Power
- 0
Creating a login form using sql server 2005 database
Hello Guys
I'm creating a login form using java swing GUI and sql server 2005 database, i can connect to the database, but i have difficulty using created username and password in my database-security-user to login in the login GUI.
I will appreciate assistance from guys in creating a login form that will display another GUI.
help me out pls!
- 05-27-2010, 07:12 PM #2
Please Present Code.
:rolleyes: ~ Sno ~ :rolleyes:
'-~ B.S. Computer Science ~-'
- 05-27-2010, 07:55 PM #3
Member
- Join Date
- May 2010
- Posts
- 7
- Rep Power
- 0
Here is code for my database creating the username and password.
CREATE LOGIN nayd13 WITH PASSWORD = 'welcome';
USE SDIM;
CREATE USER Neyds FOR LOGIN neyd13;
now my connection to database sql server 2005 is
try {
Class.forName(“com.microsoft.sqlserver.jdbc.SQLSer verDriver”);
Connection con = DriverManager.getConnection(connectionUrl);
if(con != null)
{System.out.println("connection sucessful");}
else {System.out.println("no connection");}
}
catch (SQLException e) {
e.printStackTrace();
}
catch (ClassNotFoundException cE) {
e.printStackTrace();
}
which connect sucessfuly.
well using created username and password in the database is login, which will display another Jform window application is what i'm an having diffculty writing the code for it.
ie
private void entBtnActionPerformed(java.awt.event.ActionEvent evt){
Help me here pls...
}
using my created usename and password to login and display a new window
thanx
- 05-27-2010, 08:42 PM #4
So wait... write out the steps of the process you are trying to do.
1. Login
2. Go to new window?
If these are your steps, In the login, on the btn you will have to use a select statement and compare your username to the one you typed in, than if correct, go to a new window.
so you should research passing sql statements and displaying displaying new window.:rolleyes: ~ Sno ~ :rolleyes:
'-~ B.S. Computer Science ~-'
- 05-28-2010, 09:28 AM #5
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
It's not a login, as in a user table.
He's using SQL Server security, so the login is in the connection URL...at least that's what it looks like to me?
- 05-29-2010, 09:45 AM #6
Member
- Join Date
- May 2010
- Posts
- 7
- Rep Power
- 0
Now i have difficulty writting out the code to reset user password in the database after login into the application.
Here is my code
char[] oldPass = jPasswordField1.getPassword();
String strOldPass = new String(oldPass);
char[] newPass = jPasswordField2.getPassword();
String strNewPass = new String(newPass);
char[] confPass = jPasswordField3.getPassword();
String strConfPass = new String(confPass);
try
{
Inventory objInven = new Inventory();//creating of the objectof the connection in class Inventory.
Statement stmt = objinven.con.createStatement();
ResultSet rs = stmt.getResult();
while(rs.next())
{
if(rs.getsring("Password").equals(strOldPass))
{
rs.moveToInserRow();
rs.updateString("Password", strNewPass);
rs.updateString("Password", strConfPass);
if(strNewPass.equals(strConfPass))
{
JOptionPane.showMessageDialog(this, "Password change successfuly");
}
else
{JOptionPane.showMessageDialog(this, "Password do not match");
}
}
else
{
JOptionPane.showMessageDialog(this, "Wrong old Password");
}
}
catch(SQLException ex)
{
ex.printStackTrace();
}
}
this code is to be performed when a submit button is clicked.
i have this error : Exception occurred during event dispatching: jana.lang.NullPointerException.
please help me out with this code that will allow users to change their old password to a new one in the database created by correcting my error
Thanx
- 05-29-2010, 12:24 PM #7
Senior Member
- Join Date
- Feb 2010
- Location
- Waterford, Ireland
- Posts
- 748
- Rep Power
- 4
Don't change password arrays to Strings
You defeat the reason why passwords are character arraysJava Code:char[] oldPass = jPasswordField1.getPassword(); String strOldPass = new String(oldPass); char[] newPass = jPasswordField2.getPassword(); String strNewPass = new String(newPass); char[] confPass = jPasswordField3.getPassword(); String strConfPass = new String(confPass); if(rs.getsring("Password").equals(strOldPass))
do this
Java Code:char oldPass[]=PasswordField1.getPassword(); char newPass[]=jPasswordField2.getPassword(); char confPass[]=jPassWordField3.getPassword(); // check if char arrays are equal boolean same=Arrays.equals(newPass,confPass); // change arrays when done Arrays.fill(newPass, ' '); Arrays.fill(oldPass, ' '); etc..
- 05-29-2010, 01:57 PM #8
Member
- Join Date
- May 2010
- Location
- china
- Posts
- 7
- Rep Power
- 0
Similar Threads
-
SQL server 2005 - Login failed message
By pbaudru in forum JDBCReplies: 15Last Post: 02-10-2010, 11:03 AM -
Issue with JDBC Connection to SQL Server 2005 database when default schema is changed
By NicoleVT2000 in forum New To JavaReplies: 0Last Post: 12-01-2009, 10:01 PM -
SWT login form
By Sureshgurram in forum SWT / JFaceReplies: 4Last Post: 09-07-2009, 03:14 PM -
Login form issue
By mfayaz in forum New To JavaReplies: 5Last Post: 03-27-2009, 08:35 PM -
cannot open database requested in login. Login fails
By banduskank in forum JDBCReplies: 0Last Post: 06-25-2008, 12:41 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks