制作使用数据库的Java应用程序需要了解什么?

时间:2008-11-15 12:08:12

标签: java database netbeans

由于我已经开始使用NetBeans,我已经学会了一些powerful ways来抽象创建Java数据库应用程序的过程,该过程使用自动生成的UI,bean绑定以及一些我只是模糊地理解的其他东西目前的运作(我讨厌成为新手)。问题是,我如何做我真正想做的基本事情?我读过的教程对于能够从IDE中连接到数据库以及如何创建和绑定某些UI滑块和复选框到表列等等有很大的帮助。但我在哪里可以了解如何让我自己的代码做那些东西?抽象很好,但是我现在对我所需要做的事情毫无用处。

有人可以向我推荐一些好的资源或教程来学习吗?我发现的少数证据并不像我希望我的项目正在进行中那样有用......

5 个答案:

答案 0 :(得分:4)

JDBC Tutorial是一个很好的起点

介绍

的摘录
The JDBC API is a Java API that can access any kind of tabular data, 
especially data stored in a Relational Database.

JDBC helps you to write java applications that manage these three programming 
activities:

   1. Connect to a data source, like a database
   2. Send queries and update statements to the database
   3. Retrieve and process the results received from the database in answer to 
      your query

      The following simple code fragment gives a simple example of
these three steps:
  Connection con = DriverManager.getConnection
             ( "jdbc:myDriver:wombat", "myLogin","myPassword");

  Statement stmt = con.createStatement();
  ResultSet rs = stmt.executeQuery("SELECT a, b, c FROM Table1");
  while (rs.next()) {
    int x = rs.getInt("a");
    String s = rs.getString("b");
    float f = rs.getFloat("c");
  }
      This short code fragment instantiates a DriverManager object to 
connect to a database driver and log into the database, instantiates a 
Statement object that carries your SQL language query to the database; 
instantiates a ResultSet object that retrieves the results of your query, 
and executes a simple while loop, which retrieves and displays those 
results. It's that simple. 

Google图书here上还有图书预览。

答案 1 :(得分:1)

尝试Sun的JDBC introduction

答案 2 :(得分:1)

您对JDBC感到满意,可能需要考虑使用Spring`s support for JDBC。它提供了一个比JDBC更好的API(比标准库)

访问数据库

答案 3 :(得分:0)

阅读jdbc教程后,请注意基本概念: - 连接 - 声明 - 查询 - 结果集

Db授权属于同意, query是“做什么”的描述 - 获取数据或更新, 在某些情况下,resultset可以更新(!)。

答案 4 :(得分:0)

我最后一次查看JDBC教程时,它有很多代码示例,如果它们在真实应用程序中使用,它们将成为SQL注入的一个秘诀。我不得不教一个关于JDBC的课程,我本来应该使用这个教程,但我不得不用安全讲座来补充它。

相关问题