Welcome Guest ( Log In | Register )



 
Reply to this topicStart new topic
> Java Db Help Pls
sparkx
post Nov 28 2007, 11:47 PM
Post #1


Sparkx
Group Icon

Group: [HOSTED]
Posts: 354
Joined: 11-October 06
From: Dana Point, CA, USA
Member No.: 16,496



Now I am a compleate newbie to java. Now just from saying that I will get posts that say "read the basics first" ect. I know the basics but the way I learn isn't just by going over basics. What I want to do/know is if it is possible to connect to a MySQL Database using java. Is it possible and if so how? Tutorials and links to tutorials are welcome along with maby a list of required packages and an example code of connecting/selecting data. This is for MySQL not SQL (I don't know if there is a major difference in java or not). I am currently using SDK1.4.2_16. I have various other packages installed already. I know the basics 
about java (in 3D at least) but I am compleatly clueless on Java connection to m
ysql. I think it has something to do with JDBC but I might be wrong.
Thanks for all the help,
Sparkx

This post has been edited by sparkx: Nov 28 2007, 11:49 PM
Go to the top of the page
 
+Quote Post
kelvinmaki
post Nov 29 2007, 05:51 AM
Post #2


Advanced Member
Group Icon

Group: Members
Posts: 170
Joined: 30-July 07
Member No.: 23,704



Basically, making Java application connecting to mySQL and any other database eg. ORACLE, its the same. The only different is the connection string. For mySQL, I've used:

CODE
Connection con = null;
Class.forName("com.mysql.jdbc.Driver").newInstance();
con = DriverManager.getConnection("jdbc:mysql:///test","root", "secret");


After that, use the con variable to execute all the SQL queries. For how to execute the queries, you can do a google search and you should get a lot of information.

Anyway before all the connection to mySQL database, you should import all the classes and installed all mySQL services. Hope this help.

CODE
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;


Cheers
Go to the top of the page
 
+Quote Post
sparkx
post Dec 3 2007, 11:01 PM
Post #3


Sparkx
Group Icon

Group: [HOSTED]
Posts: 354
Joined: 11-October 06
From: Dana Point, CA, USA
Member No.: 16,496



Thansk. I have been having trouble with this still. I get some errors like App notinted or something along those lines. Could anyone post the entire code for connecting and displaying entries. Just say I have a mysql database (on astahost) called testdb (I guess the name doesn't matter I could alway change it). Then display all the entries for Name that are in testdb. I learn best by jumping right into the code so you don't neccissarly need to explain it (although that would help) but what I am looking for is a complete source (unless that is to long). I have worked with mysql lots in php but for some reason when I upload my java files I can't get them to work.
Thank you very much,
Sparkx

Note: I am not exactly sure if the error I am getting is related to the script at all it may be something with my compiler. I have gotten the error on other project also that don't connect to databases, however my compiler works on simple projects still.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. java.lang.NullPointException(4)
  2. Using system date in java... How?(5)
  3. Java Unlimited(14)
  4. Array Sorting(21)
  5. What Are The Advantages Of Java Vs C++?(15)
  6. Need Help: Find Lowest Character Using Java(7)
  7. Download Java Ebooks(13)
  8. Java By Example(8)
  9. Video Streaming In Web Browser Through Java Or Jsp(1)
  10. Looking For A Java IDE(25)
  11. On Why Java Is 'c'ooler!(10)
  12. Other Sound Format Support(3)
  13. Java Phone Book(2)
  14. How To Create Exe File In Java?(13)
  15. How Do I Test A Java Aplication(11)
  1. Mozilla And Java!(2)
  2. Need To Modify Xml Attribute Using Java(4)
  3. Bluetooth And Java(5)
  4. Java Sdk Vs. Java Jdk?(2)
  5. Graphcal User Interfaces In Java(4)
  6. Loading 3d Models In Java?(2)
  7. Java Applet Loading Error(5)
  8. Setting Up Java Correctly(8)
  9. Java Java.security.accesscontrolexception(6)
  10. Simple Java Question(3)
  11. Java And Sql: Data Mismatch(6)
  12. Java Memory Leak?(0)
  13. Java Mouse Movement.(2)


 



- Lo-Fi Version Time is now: 11th October 2008 - 06:20 PM