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

using a local database

raul Alejandro Montero Cruz
Greenhorn

Joined: Jun 05, 2008
Posts: 10
hi, i'm kinda new to databases in the java world. I began serching a way to connect to databases in java, specially ODBC and all i could find out was connecting to remote databases using an url to identy them.

Is there a way to connect to a database that i have in my computer an bound the file with the .jar so i can use it cross platform?

I'm in the middle of a personal proyect and because of that i cant keep going
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39884
    
  28
Welcome to JavaRanch

I find your question a bit difficult to understand, but there is a nice simple introduction to connecting to a local database in the Java Tutorials. I think it will only answer part of your question, but it is a start.
[ September 19, 2008: Message edited by: Campbell Ritchie ]
raul Alejandro Montero Cruz
Greenhorn

Joined: Jun 05, 2008
Posts: 10
what i meant was how can i connect to a local database, save and extract information from the tables inside.

because all i found about JDBC tell me the database have to be on the internet since it ask me for the url.

hope this time is understanble
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39884
    
  28
The tutorial example I gave you does tell how to set up and use a database on your own computer. The details of connectors vary from product to product, but their documentation should tell you how to install and invoke the drivers.
raul Alejandro Montero Cruz
Greenhorn

Joined: Jun 05, 2008
Posts: 10
hey, i was reading the tutorial you gave me and i enconter some dificulties. I have Netbeans installed and it comes with glassfish V2. But for some reason when i try to to start the Java DB thats located in the services window it says : "Could not listen on port 1527 on host localhost." , do i have to setup a server or something?

i need to pass this step to be able to finish the tutorial

P.S.: I stared the Glassfish server and it keep telling me the same.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39884
    
  28
Which database are you using? You don't usually need a server for access to a database on your own computer, just a Driver.
raul Alejandro Montero Cruz
Greenhorn

Joined: Jun 05, 2008
Posts: 10
i really dont know, since i'm using the the Netbeans IDE wich comes with GlassFish V2. and as i read is is some kind of RDMBS(Relationa Database Management System). How can i check out what drivers i'm using?
raul Alejandro Montero Cruz
Greenhorn

Joined: Jun 05, 2008
Posts: 10
i just fnish the tutorial, i did'nt know how to use the dervy database but insted i used a Mysql connection wich is lot easier.

anyway, now i know how to connect to them but how do i use the operations like save data into the database, extract it and delete it?

Thanks for your help. the tutorial was very helpfull!
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39884
    
  28
You can do what it says in the tutorial. You can pass messages like

"INSERT INTO my_table VALUES ('Raul', 'Alejandro', 'Montero', 'Cruz');"

followed by

"SELECT * FROM my_table;" which returns a ResultSet.
raul Alejandro Montero Cruz
Greenhorn

Joined: Jun 05, 2008
Posts: 10
what i mean is make queries IN the program so i can manipulate the data WHEN the program is running, not when is being coded.

is like when i press a button i can INSERT into a table or DROP or UPDATE or anything the SQL languaje can do with queries.

if the tutorial said that, i did'nt saw it.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39884
    
  28
You add a Listener to your button the same way you would for anything.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: using a local database