Spencer
Spencer

Reputation: 22370

Calling MySQL database using Java

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.

Upvotes: 0

Views: 920

Answers (2)

Buhake Sindi
Buhake Sindi

Reputation: 89169

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.

Upvotes: 2

Brian Agnew
Brian Agnew

Reputation: 272237

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.

Upvotes: 0

Related Questions