English 中文(简体)
用Java调用MySQL数据库
原标题:Calling MySQL database using Java
  • 时间:2010-10-13 16:47:00
  •  标签:
  • java
  • mysql

嗨,我刚开始编程,并尝试使用Java从MySQL数据库调用表。以下是我的Java代码:

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();
}
}

我希望能够从MySQL调用:a、b、c、p1、p2和p3。a、 b和c表示客户ID s。P1、P2和P3表示与这些客户ID s相关联的表中的一个由十个数字组成的字符串。我还想将此代码的输出存回MySQL中的新表中。提前谢谢。

最佳回答

你必须学会如何做JDBC(Java数据库连接)与MySQL。下载MySQL连接器/J(适用于Java的MySQL连接器),然后关注this向您展示了一个逐步设置MySQL的方法以及如何在java中使用MySQL。

希望这能有所帮助。

问题回答

您需要使用JDBC(Java数据库连接)API以及适用于MySQL的JDBC驱动程序。

这里有一个页面,包含JDBC驱动程序链接和教程等。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签