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

时间:2023-01-24 13:00:41

Since I've started using NetBeans, I've learned of some powerful ways to abstract away the process of creating Java database applications with automatically generated UI, beans bindings, and a bunch of other stuff I only vaguely understand the workings of at the moment (I hate being a newb). Problem is, how do I do the basic stuff I actually want to do? The tutorials I've read make a big deal about being able to connect to and mess around with a database from within the IDE, or how to create and bind some UI sliders and checkboxes to table columns, etc. But where can I learn about how to make my own code do that stuff? Abstraction is nice and all, but it's quite useless to me at the moment for what I need done.

自从我开始使用NetBeans以来,我已经学会了一些强大的方法来抽象创建Java数据库应用程序的过程,其中包括自动生成的UI,bean绑定以及其他一些东西,我只是模糊地理解了目前的工作原理。 (我讨厌成为一个新人)。问题是,我该如何做我真正想做的基本事情?我读过的教程非常重要,可以从IDE中连接到数据库并弄乱它,或者如何创建和绑定一些UI滑块和复选框到表列等等。但我在哪里可以了解如何让我自己的代码做那些东西?抽象很好,但是对于我现在需要做的事情来说,这对我来说毫无用处。

Can anyone refer me to some good resources or tutorials to learn this? The few I've found aren't proving as useful as I'd hoped to get my project underway...

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

5 个解决方案

#1


4  

The JDBC Tutorial is a good starting point

JDBC教程是一个很好的起点

A snippet from the intro

来自介绍的片段

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. 

There is also a book preview on Google Books here.

此处还有Google图书预订。

#2


1  

Try the JDBC introduction from Sun.

试试Sun的JDBC介绍。

#3


1  

One you get comfortable with JDBC, you might want to consider using Spring`s support for JDBC. It provides a much nicer API (than the standard libraries) for accessing a database via JDBC

您对JDBC感到满意,可能需要考虑使用Spring对JDBC的支持。它提供了比通过JDBC访问数据库更好的API(比标准库)

#4


0  

After reading jdbc tutorials take some attention to the base concepts: - connection - statement - query - resultset

阅读jdbc教程后,请注意基本概念: - connection - statement - query - resultset

Db authorisation belongs to conntection, query is the description of "what to do" - fetch data or update, resultset could be updatable(!) in some cases.

Db授权属于连接,查询是“做什么”的描述 - 获取数据或更新,结果集在某些情况下可以更新(!)。

#5


0  

The last time I looked at the JDBC tutorial, it had a lot of code examples in it that would be a recipe for SQL Injection if they were used in a real app. I had to teach a class on JDBC and I was supposed to use the tutorial, but I had to supplement it with a security lecture.

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

#1


4  

The JDBC Tutorial is a good starting point

JDBC教程是一个很好的起点

A snippet from the intro

来自介绍的片段

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. 

There is also a book preview on Google Books here.

此处还有Google图书预订。

#2


1  

Try the JDBC introduction from Sun.

试试Sun的JDBC介绍。

#3


1  

One you get comfortable with JDBC, you might want to consider using Spring`s support for JDBC. It provides a much nicer API (than the standard libraries) for accessing a database via JDBC

您对JDBC感到满意,可能需要考虑使用Spring对JDBC的支持。它提供了比通过JDBC访问数据库更好的API(比标准库)

#4


0  

After reading jdbc tutorials take some attention to the base concepts: - connection - statement - query - resultset

阅读jdbc教程后,请注意基本概念: - connection - statement - query - resultset

Db authorisation belongs to conntection, query is the description of "what to do" - fetch data or update, resultset could be updatable(!) in some cases.

Db授权属于连接,查询是“做什么”的描述 - 获取数据或更新,结果集在某些情况下可以更新(!)。

#5


0  

The last time I looked at the JDBC tutorial, it had a lot of code examples in it that would be a recipe for SQL Injection if they were used in a real app. I had to teach a class on JDBC and I was supposed to use the tutorial, but I had to supplement it with a security lecture.

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