Results 1 to 3 of 3
- 04-16-2008, 11:32 PM #1
Member
- Join Date
- Apr 2008
- Posts
- 4
- Rep Power
- 0
Java program that transfers stock prices to MySQL database
Hi
Jag want to bring stock prices from csv files (excel) on the internet and copy them to a MySQL database through a Java program. I have downloaded the following:
-Eclipse
-MySQL server 5.0
-MySQL Connector/J
With this installed I should be able to edit mySQL databases through JDBC, but I don't know so much more. Can somebody help me to get started?
- 04-17-2008, 03:45 PM #2
have some tutorials about it first....Can somebody help me to get started?
sukatoa
- 04-17-2008, 05:02 PM #3
You will need to create a new Java project in Eclipse. Once complete, right click the project in the Package window and click 'Properties' Then navigate to 'Java Build Path' Click 'Add JARs' and locate the MySQL JDBC driver. Add it and click OK..
Then you can use this code to connect to the database:
Java Code:import java.sql.*; public class Connect { public static void main (String[] args) { Connection conn = null; try { String userName = "testuser"; String password = "testpass"; String url = "jdbc:mysql://localhost/test"; Class.forName ("com.mysql.jdbc.Driver").newInstance (); conn = DriverManager.getConnection (url, userName, password); System.out.println ("Database connection established"); } catch (Exception e) { System.err.println ("Cannot connect to database server"); } finally { if (conn != null) { try { conn.close (); System.out.println ("Database connection terminated"); } catch (Exception e) { /* ignore close errors */ } } } } }Did this post help you? Please
me! :cool:
Similar Threads
-
problem in connecting to mysql database
By nancyv in forum Java ServletReplies: 6Last Post: 04-02-2008, 11:33 AM -
Problem with jTable that is binded with a table in MySQL Database
By rajkenneth in forum NetBeansReplies: 0Last Post: 03-29-2008, 03:36 PM -
Help needed with updating mysql database
By SilentCodingOne in forum New To JavaReplies: 1Last Post: 12-11-2007, 10:23 PM -
How to execute an External Program through Java program
By JavaBean in forum Java TipReplies: 0Last Post: 10-04-2007, 09:33 PM -
connecting to mysql database
By javagal in forum NetBeansReplies: 2Last Post: 08-04-2007, 12:36 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks