Solved

Database

Posted on 2003-12-08
10
217 Views
Last Modified: 2006-11-17
Well, everytime i want to use Database in my Java app, i have to go to ODBC to select my database and add it. But my application couldnt locate the database if i move it to another folder..

so how am i suppose to make it like, no matter which folder i move my database, my application can still locate it? cause i couldnt tell where the user will put the application files and database..
0
Comment
Question by:InNoCenT_Ch1ld
  • 5
  • 4
10 Comments
 
LVL 92

Expert Comment

by:objects
ID: 9901428
are we talking about an access db?
0
 
LVL 3

Author Comment

by:InNoCenT_Ch1ld
ID: 9901582
yup..
wait, are you trying to "say" that only MS Access has this stupid problem?
0
 
LVL 92

Expert Comment

by:objects
ID: 9901597
not sure if its only access (probably not) but yes it is an access problem, because in your dsn you specify the location of the access db file. If you move it you need to update your dsn.
0
 
LVL 3

Author Comment

by:InNoCenT_Ch1ld
ID: 9901665
so, how to avoid it? or should i use other db software?

normally how you guys do with your database? cause i dun want to set the User DNS.. (can it be done with another db?)
0
 
LVL 92

Expert Comment

by:objects
ID: 9901696
if you don't want to use a DSN then you can specify the filename in your connection string. But you can't avoid specifying the filename somewhere as it needs to know where it is so it can be accessed.

Other DBMS (eg. mysql, SQL server etc) do not require you to specify a filename because the db is communicated with using sockets and not by directly accessing the filesystem.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 3

Author Comment

by:InNoCenT_Ch1ld
ID: 9901769
guess i have to "quit" the stupid MS Acess already... ;(
0
 
LVL 3

Author Comment

by:InNoCenT_Ch1ld
ID: 9901797
btw, what you mean by "the db is communicated with using sockets "?
0
 
LVL 6

Expert Comment

by:dorothy2
ID: 9901879
1.  You could have a properties file and put the filepath there.
2.  You could pass the connection string or the filepath in as a command line arg.

Depends on what your app does and how secure it has to be. This is terrible for security, but it would allow you to easily modify where the database is without hardcoding it in your source code or changing the dsn.

It's not a good idea to be moving the database file around. If you need to change it because you are deploying to another computer, there is probably a way to use relative path names rather than absolute path names ( "..\database.mdb" instead of "C:\Java\Myapp\Mydatabase\database.mdb"

Dorothy
0
 
LVL 92

Accepted Solution

by:
objects earned 25 total points
ID: 9901913
> what you mean by "the db is communicated with using sockets "

instead of accessing the db file directly, instead the interaction with the database is performed by connection to the database application.
0
 
LVL 92

Expert Comment

by:objects
ID: 9902252
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
@SBGen Method 3 37
HTTPSessionBindingListernter not configured in deployment descriptor 2 36
java stored proc example 9 21
expectj telnet failing 5 23
For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now