aspose file tools*
The moose likes JDBC and the fly likes Application login Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Application login" Watch "Application login" New topic
Author

Application login

Samson Mlati
Ranch Hand

Joined: Feb 23, 2009
Posts: 41

Hi,

I am working on a stand alone swing application with a mysql back end. I need suggestions on how to go about connecting to the database without having to hard code values in an xml file, I want a user to type in their username, password on a form then use that to connect to the database.

Thanks


Best,
Mlati
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18907
    
    8

Okay. You posted this in the JDBC forum so I assume you don't have a problem with the GUI part of your question.

You can put the user ID and password in the JDBC URI which you use to connect to MySQL, or you can use the form of DriverManager.getConnection which has parameters specifically for user ID and password. I would choose the latter method myself.
Samson Mlati
Ranch Hand

Joined: Feb 23, 2009
Posts: 41

Paul Clapham wrote:Okay. You posted this in the JDBC forum so I assume you don't have a problem with the GUI part of your question.

You can put the user ID and password in the JDBC URI which you use to connect to MySQL, or you can use the form of DriverManager.getConnection which has parameters specifically for user ID and password. I would choose the latter method myself.


Well, I kinda see what you mean. It seems like there needs to exist a data source somewhere since the stand alone application must run on the database server anyway. I figure I can use the datasource to query and verify if the username/password supplied is valid.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18907
    
    8

Samson Mlati wrote:It seems like there needs to exist a data source somewhere since the stand alone application must run on the database server anyway.


I don't understand this at all. Database server? Does that refer to the MySQL server which you are running? If so then you just connect to it in the basic way which is described in all the JDBC tutorials. "Data source" is usually a term which refers to an object configured into an web application server. You didn't mention any such thing in your original post, which is why I'm confused about that statement.
Samson Mlati
Ranch Hand

Joined: Feb 23, 2009
Posts: 41

Paul Clapham wrote:
Samson Mlati wrote:It seems like there needs to exist a data source somewhere since the stand alone application must run on the database server anyway.


I don't understand this at all. Database server? Does that refer to the MySQL server which you are running? If so then you just connect to it in the basic way which is described in all the JDBC tutorials. "Data source" is usually a term which refers to an object configured into an web application server. You didn't mention any such thing in your original post, which is why I'm confused about that statement.


You are right about datasource, i'm sorry. I meant an xml file with database properties. The swing application will run on the same machine as the database is what i meant by MySQL server. Thanks, I think I've figured out what I need to do.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Application login