This week's giveaways are in the MongoDB and Jobs Discussion forums.
We're giving away four copies of Mongo DB Applied Patterns and 4 resume reviews from Five Year Itch and have the authors/reps on-line!
See this thread and this one for details.
The moose likes Swing / AWT / SWT and the fly likes session in desktop application? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Mongo DB Applied Patterns this week in the MongoDB forum
or a resume review from Five Year Itch in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "session in desktop application?" Watch "session in desktop application?" New topic
Author

session in desktop application?

Punit Jain
Ranch Hand

Joined: Aug 20, 2011
Posts: 902
hello , i create a desktop application, when user run that, a login screen appears, and only after successful login he will get access to that software.
but i want afetr user logged in, if he again run that application he should not get login screen again.
so what can i do for this, sessions are there in desktop applications??
also i want to know my login code is okay or not, here is my login code:



Thank you.
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2407
also i want to know my login code is okay or not

It's not, it's wide open to SQL injection attacks. Read up on PreparedStatement.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 8430

Punit Jain wrote:
so what can i do for this, sessions are there in desktop applications??

No. But you can use the preference API


[Donate a pint, save a life!] [How to ask questions] [Onff-turn it on!]
Ranganathan Kaliyur Mannar
Bartender

Joined: Oct 16, 2003
Posts: 914
    
    2

Your login code is very poor. You have declared a PreparedStatement and are calling 'prepareStatement' too, but it is a waste because there is nothing there to prepare in the query.

As for session, I don't think your definition of session is correct. Even in a web app, when I open the browser and log in, my 'session' is alive only till my browser is open. If I close the browser and re-open again, my session is lost and I have to re-login again. So, I think the same would apply to desktop too.

If you want the functionality that you have mentioned, you have to write your own logic, but don't call it a 'session'.


Ranga.
SCJP 1.4, OCMJEA/SCEA 5.0.
Punit Jain
Ranch Hand

Joined: Aug 20, 2011
Posts: 902
okay i have done changes to my login code, here is what i changed:
Punit Jain
Ranch Hand

Joined: Aug 20, 2011
Posts: 902
also with my earlier login code i just tried for sql injuction with below login id and password:

user:admin
pass:’ or 1=1–

but it showing me exception only, not giving my user id and password.??
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2407
How about this as a password:

'; drop table AdminLogin; --
Punit Jain
Ranch Hand

Joined: Aug 20, 2011
Posts: 902
no it's not dropped my table, it showing me one exception:
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2407
Well, just keep at it and eventually you may succeed.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: session in desktop application?
 
Similar Threads
login with Struts2&MySQL
strange reading cookie problem
Beginner needs help!!
Where to write Validation
org.hibernate.MappingException: Unknown entity: