Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 02-04-2009
Member
 
Join Date: Jan 2009
Posts: 38
authentication (java / sql)

Hello,
I make a java program with a SQL database.
My problem:
I made a window (GUI) for a login.
On the other hand, I have a table with an identifying and a password.
I am unable to check if the IDs exist in the sql table.
So in fact the thing is that it can not take names, so it can not compare ... how can I do?
Thank you in advance
Reply With Quote
  #2  
Old 02-04-2009
Member
 
Join Date: May 2008
Posts: 2,383
Re: authentication (java / sql)

try following code

Quote:
import java.sql .*;
public class Pass (

public static void main (String args []) (
Statement statement = connection.createStatement (/ / error in line cett
ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY);
String sql = "SELECT * FROM user";
ResultSet result = statement.executeQuery (sql);
while (resultat.next ()) (
String login = resultat.getString (1);
String pass = resultat.getString (2);
resultat.getRow int row = ();
System.out.println ( "Data in row" + row);
System.out.println ( "id:" + login + "name:" + pass);
)
)
)
Reply With Quote
  #3  
Old 02-04-2009
Member
 
Join Date: Jan 2008
Posts: 1,515
Re: authentication (java / sql)

Do not worry, all mac users are not as embittered as

Indeed, the connection is not established, here's one answer:
Code:
Quote:
/ / Connection settings to the database
String url = "jdbc: yourBDDAccess" / / ex: postgresql: / / localhost / postgres
String login = "yourBDDLogin";
String password = "youBDDPass";

try
(
/ / Connection
Connection connection = DriverManager.getConnection (url, login, password);
/ / interaction with the base
Statement st = connection.createStatement ();

/ / Treatment

st.close ();
connection.close ();
)
catch (SQLException sqle)
(
sqle.printStackTrace ();
)
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "authentication (java / sql)"
Thread Thread Starter Forum Replies Last Post
MS ADAM authentication with Java app - can authenticate with local ADAM accounts; CANNOT authenticate with proxy accounts sync'd from AD domain bert213 Active Directory 1 22-05-2011 03:41 AM
Mozilla 3.6.8: asking for authentication Hishem-Remashiya Technology & Internet 4 04-11-2010 01:49 AM
External Authentication with Java Card through HSM FFCookie Software Development 5 24-07-2010 03:29 AM
SSH key authentication Linux-Us Networking & Security 5 21-12-2009 02:44 PM
NTLM authentication with Java Web Start? Shaan12 Software Development 3 09-11-2009 07:07 PM


All times are GMT +5.5. The time now is 03:59 AM.