简体   繁体   中英

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.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM