• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

using a local database

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You add a Listener to your button the same way you would for anything.
 
It's a tiny ad only because the water is so cold.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic