简体   繁体   English

创建使用数据库的Java应用程序我需要知道些什么?

[英]What do I need to know to make a Java application that uses a database?

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). 自从我开始使用NetBeans以来,我已经学到了一些强大的方法来抽象化具有自动生成的UI,Bean绑定以及其他很多东西的Java数据库应用程序的创建过程,而我目前对此尚不清楚。 (我讨厌成为新手)。 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? 我读过的教程对在IDE中能够连接和处理数据库以及如何创建和绑定一些UI滑块和复选框到表列等有很大帮助。但是我在哪里可以了解到如何使自己的代码做到这一点? Abstraction is nice and all, but it's quite useless to me at the moment for what I need done. 抽象是很好的方法,但对于我现在需要做的事情,它对我来说毫无用处。

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... 我发现的一些事实并没有像我希望让我的项目进行那样有用...

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 . 还有上谷歌图书提供书籍预览这里

试试Sun的JDBC简介

One you get comfortable with JDBC, you might want to consider using Spring`s support for JDBC . 一个熟悉JDBC的人,您可能要考虑使用Spring对JDBC的支持 It provides a much nicer API (than the standard libraries) for accessing a database via JDBC 它提供了比标准库更好的API(比标准库更好),用于通过JDBC访问数据库

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. 我上次查看JDBC教程时,其中包含许多代码示例,如果它们在实际应用中使用的话,它们可能是SQL注入的秘诀。 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的课程,并且应该使用本教程,但是我必须通过安全性讲座来补充它。

After reading jdbc tutorials take some attention to the base concepts: - connection - statement - query - resultset 阅读jdbc教程后,请注意以下基本概念:-连接-语句-查询-结果集

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授权属于连接,查询是对“做什么”的描述-获取数据或更新,在某些情况下结果集可能是可更新的(!)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我需要在使用我的应用程序的每台PC上创建数据库吗? - Do I need to create Database on each PC that uses my application? 我如何知道我的Java应用程序是否使用“本机代码”? - How do I know whether my Java application uses “native code”? 如何知道Java应用程序使用的所有类/ jar文件 - How to know what all classes / jar files a Java application uses 要将JTA集成到Java SE应用程序中,我需要做什么? - What do I need to do to integrate JTA into a Java SE application? 我是否需要Mac来制作Java应用程序包? - Do I need a Mac to make a Java application bundle? 在维护具有大量线程的Java应用程序时,我需要了解什么? - What do I need to know when maintaining a Java app with a large number of threads? 使用Caesar Cipher身份验证用Java编写客户端服务器套接字程序时,我需要知道什么? - What do I need to know to write a client server socket program in Java using Caesar Cipher authentication? 我需要使用Java在mysql中创建新数据库 - I need to make new database in mysql with Java 我如何知道Java for Android Studio的Firebase数据库中的对象类型是什么? - How do I know what type of object is in a firebase database in java for android studio? 我需要调用数据库的步骤是什么 - what is the step do i need to call database
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM