• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Application login

 
Samson Mlati
Ranch Hand
Posts: 41
Hibernate Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Paul Clapham
Sheriff
Posts: 21322
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 41
Hibernate Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21322
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 41
Hibernate Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic