views:

39

answers:

2

Hi I am new to programming and trying to call a table from a MySQL database using Java. Here is what my Java code looks like:

public static void main(String[] args){ 
        double p1[] = {10000000,2,5,7,5,6,6,8,9,3};
        double p2[] = {100,3,4,3,4,1,2,5,1,5};
        double p3[] = {1,2,6,4,5,6,7,8,9,1};
        Expert_Score x = new Expert_Score(a, p1);
        Expert_Score y = new Expert_Score(b, p2);
        Expert_Score z = new Expert_Score(c, p3);
        Z_score scrCalc = new Z_score();
        scrCalc.Z_Calc(x,y,z);
        scrCalc.print();
}
}

I want to be able to call from MySQL: a, b, c, p1, p2 and p3. a,b and c represent Customer ID's. P1, P2, and P3 represent a string of ten numbers from a table associated with those Customer Id's. I also want to deposit the output of this code back into a new table in MySQL. Thanks in advance.

A: 

You need to use the JDBC (Java Database Connectivity) API plus the appropriate JDBC driver for MySQL.

Here's a page with the JDBC driver links plus tutorials etc.

Brian Agnew
+2  A: 

You will have to learn how to do JDBC (Java DataBase Connectivity) with MySQL. Download MySQL Connector/J (MySQL Connector for Java) and follow an article such as this which shows you a step-by-step approach on setting up MySQL and how to play with MySQL in java.

Hope this helps.

The Elite Gentleman
After you've done everything recommended here, I suggest you find and download the commons-db package from Apache. It has a lot of utility classes and methods that will help you reduce the amount of code you have to write and keep things much simpler for you.
Alex Marshall