• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Connecting to SQL database

 
Karol Dziedzic
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I need to make a program which will connect to SQL database with given informations (IP, database name, server name, login and password), which I will receive from someone else. I know how to connect to database with access informations already includet in program code, and when I try to log in program just compare that informations with my. I don't know how to connect to database when I don't know such informations, and I can't put them into the code. I would be greatfull for any help

PS. I hope my explanation is quite clear;) My english is not so good;)
 
Ivan Krasic
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Karol Dziedzic wrote:Hi,

I need to make a program which will connect to SQL database with given informations (IP, database name, server name, login and password), which I will receive from someone else. I know how to connect to database with access informations already includet in program code, and when I try to log in program just compare that informations with my. I don't know how to connect to database when I don't know such informations, and I can't put them into the code. I would be greatfull for any help

PS. I hope my explanation is quite clear;) My english is not so good;)


What kind SQL Database ?
What are you using now to connect ? (Hibernate , JDBC ... ?)
 
Karol Dziedzic
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have SQL database with table (6 rows x 6 columns) with just some numbers. I am using JDBC driver.
 
Ivan Krasic
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Karol Dziedzic wrote:I have SQL database with table (6 rows x 6 columns) with just some numbers. I am using JDBC driver.


i mean oracle or mysql ?

anyway if i understand you good , you want to connect to external database using a Java Standart Application

the method is same you are doing you just need to change ip (localhost with external ip)

however will not work as you think as the external server is behind firewall and so connection rejected

so it might that your problem why dont connect
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65342
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Karol Dziedzic wrote:I don't know how to connect to database when I don't know such informations, and I can't put them into the code.

If this is not a web app, I'd explore putting the values into a properties file.

If this is a Servlet web app, look into using the container's connection pool and configure the pool with the data values. This configuration will be container-specific.
 
Karol Dziedzic
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Problem solved
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic