jdbc programming

AI权益加码!Claude Code、Cursor等20+工具免费用! 购周边限时加赠Coding Plan Lite,畅享主流AI工具!学习进阶更高效! 阅读详情
jdbc programming

1 transation
 performance it is not easy to say , turn off auto-commiting it will cut down on the number of commits.decreasse the comunication between  client and the dbserver and but the db need to hold the locks on multiple statements.
 turn on the auto-commits , in case where there may be conflicts with other users, turn on auto-commiting will improve the preformance because no lock need to hode, but it will caused conflicts.
transaction isolation :control the dirty data, saving points is a point in a transation.

SQLWarning warning = stmt.getWarnings(); if (warning != null) { System.out.println("/n---Warning---/n"); while (warning != null) { System.out.println("Message: " + warning.getMessage()); System.out.println("SQLState: " + warning.getSQLState()); System.out.print("Vendor error code: "); System.out.println(warning.getErrorCode()); System.out.println(""); warning = warning.getNextWarning(); } }

2, rows order in result set dose nothing with the db

3, insert row, every rs has it.

4, commit is means using the sql statement ,and insertRow or updateRow is means using the jdbc api.

5, addBatch(sqlstring) executeBatch() return a int array(), its execution order is fixed, support parameterized batch


 

1, SQL types:

sql date ,time and timestamp , but java only have the date, it can repsents all the sql date types.

data returned from result set mostly is sql types.

jdbc 3.0 types , blob , clob, array, struct , ref.
udt is corresponding to struct, ref is ref.

 the program example :

while (rs.next()) { int storeNo = rs.getInt("STORE_NO"); Struct location = (Struct)rs.getObject("LOCATION"); Object[] locAttrs = location.getAttributes(); Array coffeeTypes = rs.getArray("COF_TYPE"); String[] cofTypes = (String[])coffeeTypes.getArray(); Ref managerRef = rs.getRef("MGR"); PreparedStatement pstmt = con.prepareStatement( "SELECT MANAGER FROM MANAGERS WHERE OID = ?"); pstmt.setRef(1, managerRef); ResultSet rs2 = pstmt.executeQuery(); rs2.next(); Struct manager = (Struct)rs2.getObject("MANAGER"); Object[] manAttrs = manager.getAttributes(); System.out.print(storeNo + " "); System.out.print(locAttrs[0] + " " + locAttrs[1] + " " + locAttrs[2] + ", " + locAttrs[3] + " " + locAttrs[4] + " "); for (int i = 0; i < cofTypes.length; i++) System.out.print(cofTypes[i] + " "); System.out.println(manAttrs[1] + ", " + manAttrs[2]); rs2.close(); pstmt.close(); } rs.close(); stmt.close(); con.close(); } catch(BatchUpdateException b) { System.err.println("-----BatchUpdateException-----"); System.err.println("SQLState: " + b.getSQLState()); System.err.println("Message: " + b.getMessage()); System.err.println("Vendor: " + b.getErrorCode()); System.err.print("Update counts: "); int [] updateCounts = b.getUpdateCounts(); for (int i = 0; i < updateCounts.length; i++) { System.err.print(updateCounts[i] + " "); } System.err.println(""); } catch(SQLException ex) { System.err.println("SQLException: " + ex.getMessage()); System.err.println("SQLState: " + ex.getSQLState()); System.err.println("Message: " + ex.getMessage()); System.err.println("Vendor: " + ex.getErrorCode()); }


 2, oracle jdbc driver, after u set up the connecting with oracle server, conn.getCatalog() will return null, and also u can't set the catalog, so u only can see the things which only belong to this user.like the tables, viewes, procedures.this dose make sense.


 



Java数据库编程与JDBC:深入理解JDBC驱动与SQL操作 本文通过Pratik Patel的《Java Database Programming with JDBC》一书,深入探讨了如何使用JDBC驱动程序连接数据源,创建和操作数据库表,以及通过SQL语句进行数据的维护和查询。文章详细介绍了SQL中数据类型的选择,如何创建和修改表结构,以及如何通过DQL和DML进行数据的增删改查。此外,还探讨了如何使用JDBC-ODBC桥接器连接到ODBC数据源,并讨论了安全限制和未来可能的解决方案。 阅读详情

相关推荐

JDBC编程接口的深入理解与应用

本文深入探讨了JDBC编程中ResultSet和Statement接口的核心方法和属性,以及SQL异常处理机制。通过分析具体的方法和构造函数,帮助开发者更好地理解如何在Java中操作数据库,包括如何处理查询结果和执行SQL语句,以及如何处理可能出现的异常情况。

weixin_36122351的博客 403

java语言sql接口 jdbcprogram.rar

java语言sql接口 jdbcprogram.rar

深入理解JDBC编程与数据库交互

本文深入解析了JDBC(Java Database Connectivity)技术的细节,涵盖了从数据库的基本访问、数据类型转换到异常处理等多个方面。通过丰富的实例代码和具体的操作指南,帮助读者更好地理解和掌握如何使用Java进行数据库编程,以及如何处理常见的数据库交互问题。

weixin_36122351的博客 327

jdbc-program:jdbc程序

jdbc程序 jdbc程序

JDBC快速入门

基本代码 注意事项 JDBC要与你下载的数据库兼容,否则会出现错误

ProgramBoy001的博客 166

JDBC编程步骤概述

JDBC编程分为六步: 第一步:**注册驱动**。 第二步:**连接驱动** 第三步:**获取数据库操作对象** 第四步:**执行sql语句** 第五步:**处理sql语句执行结果** 第六步:**释放资源*

Mj_yong的博客 2787

High-Performance Oracle JDBC Programming

 High-Performance Oracle JDBC ProgrammingLearn how to improve performance of Oracle-driven JDBC programs by leveraging connection and statement pooling features.By Yuli VasilievPublished April 200

hakunamatata2008的专栏 4683

Expert Oracle JDBC Programming

版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章原始出版、作者信息和本声明。否则将追究法律责任。http://blog.csdn.net/topmvp - topmvpWith Oracle in the process of de-supporting SQLJ, JDBC is now really the only recommended means of interfacin

TopMVP 703

Java Programming with Oracle JDBC

<br /><br />Performance is usually considered an issue at the end of a development cycle when it should really be considered from the start. Often, a task called "performance tuning" is done after the coding is complete, and the end user of a program compl

咖啡牛奶不加糖 599

JAVA复习四——MultiThread、JDBC、Network programming

这三章节基本知识点不是很多,重点是代码的编写。接下来我将以三道例题来分别讲解这三个知识点。

lyhizjj的博客 518

Practically Groovy: JDBC programming with Groovy

Practically Groovy: JDBC programming with Groovy Practically Groovy: JDBC programming with Groovyimport groovy.sql.Sql class GroovySq...

99

Expert Oracle JDBC Programming by R.M. Menon

Title: Expert Oracle JDBC Programming Author: R.M. Menon ISBN: 159059407X Publisher: Apress Book Binding: Paperback Category: Computer Books: Database Format: PDF Pages: 708 pages Size: 2.89 M

Linhanshi Blog 1021

Connecting to Oracle through JDBC - Oracle 9i Java Programming

DBConnection.javaimport java.sql.DriverManager;import java.sql.Connection;import java.sql.SQLException;import ja...

congpengru2605的博客 110

Java JDBC编程中的数据类型与接口

本篇博客文章深入探讨了Java JDBC编程中的核心概念,包括对Numeric类的操作方法、时间相关类的使用,以及JDBC中的主要接口和类的作用。通过对章节内容的详细解读,我们将理解如何在数据库编程中处理复杂的数值运算、时间数据和数据库交互。

weixin_36122351的博客 834

深入理解JDBC驱动程序的实现

本文深入探讨了JDBC驱动程序的工作原理,特别是在初始化连接和创建Statement对象方面。通过分析SimpleText驱动程序的源代码,我们了解了如何在保持Driver类实现尽可能小的同时,完成数据库连接和SQL语句的执行。此外,还介绍了JDBC规范中的内省能力,通过getMetaData方法获取数据库信息的重要性,以及如何处理JDBC中的循环依赖问题。

weixin_36122351的博客 321

深入理解JDBC编程与数据库交互机制

本文深入探讨了Java数据库编程中JDBC的核心概念和工作机制,包括Statement对象的创建、ResultSet对象的处理、以及数据参数设置等关键步骤。通过Pratik Patel所著的《Java Database Programming with JDBC》章节内容,我们了解了如何利用JDBC API与数据库进行高效交互。

weixin_36122351的博客 413
上一篇: about servlet
下一篇: thinking in java 3 notes
victorpgx
博客等级 码龄21年 1粉丝 6原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值