String connectionURL = "jdbc:mysql://localhost:3306/test";
// Change the connection string according to your db, ip, username and password
Connection con = null;
try {
// Load the Driver class.
Class.forName("com.mysql.jdbc.Driver");
// If you are using any other database then load the right driver here.
// Create the connection using the static getConnection method
con = DriverManager.getConnection(connectionURL, "aaa", "aaaa");
// Create a Statement class to execute the SQL statement
Statement stmt = con.createStatement();
Random random = new Random();
int status = random.nextInt(2);
System.out.println(status);
String sql = "update test set status = " + status + " where id = 1";
stmt.executeUpdate(sql);
} catch (SQLException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
} finally {
if(con != null) {
try {
con.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
分享到:
相关推荐
- basic:展示了Spring Data JDBC的基本用法。 - immutables:展示了使用Immutables的Spring Data JDBC用法。 4. Spring Data JPA: - eclipselink:展示了如何在Spring Boot和Eclipselink中使用Spring Data JPA...
Chapter 17 - Visual Basic, C#, ODBC Part IV - Reference Chapter 18 - SQL Reference Chapter 19 - MySQL Tools Chapter 20 - API Reference Part V - Appendices Appendix A - Glossary Appendix...
This example-driven book for Java developers delves into the framework's basic features, as well as advanced concepts such as containers. You'll learn how Spring makes Java Messaging Service easier ...
are a Visual Basic programmer using ODBC, a Java programmer using EJBs and JDBC, or a Perl programmer using DBI Perl. This book does not promote any specific application architecture; it does not ...
3.3. JDBC connections 3.4. Optional configuration properties 3.4.1. SQL Dialects 3.4.2. Outer Join Fetching 3.4.3. Binary Streams 3.4.4. Second-level and query cache 3.4.5. Query Language Substitution...
org.geotools.data.jdbc.attributeio org.geotools.data.jdbc.datasource org.geotools.data.jdbc.fidmapper org.geotools.data.jdbc.referencing org.geotools.data.memory org.geotools.data.mif org.geo...
The author also walks you through, from end to end, the design and implementation of a batch process based upon a theoretical real-world example. This includes basic project setup, implementation, ...
* Client JDBC connector based on the JDBC API, a custom request XML format and the JDBC WebRowSet interface for XML responses. * Client FILE connector supports GET, PUT and DELETE methods on files ...
A Complete Example Section 16.5. Conclusion Chapter 17. Using MySQL Stored Programs with .NET Section 17.1. Review of ADO.NET Basics Section 17.2. Using Stored Programs in ADO.NET Section ...
5. 对象/关系数据库映射基础(Basic O/R Mapping) 5.1. 映射定义(Mapping declaration) 5.1.1. Doctype 5.1.2. hibernate-mapping 5.1.3. class 5.1.4. id 5.1.5. composite-id 5.1.6. 鉴别器...
5. 对象/关系数据库映射基础(Basic O/R Mapping) 5.1. 映射定义(Mapping declaration) 5.1.1. Doctype 5.1.2. hibernate-mapping 5.1.3. class 5.1.4. id 5.1.5. composite-id 5.1.6. 鉴别器...
5. 对象/关系数据库映射基础(Basic O/R Mapping) 5.1. 映射定义(Mapping declaration) 5.1.1. Doctype 5.1.2. hibernate-mapping 5.1.3. class 5.1.4. id 5.1.5. composite-id 5.1.6. 鉴别器...
5. 对象/关系数据库映射基础(Basic O/R Mapping) 5.1. 映射定义(Mapping declaration) 5.1.1. Doctype 5.1.2. hibernate-mapping 5.1.3. class 5.1.4. id 5.1.5. composite-id 5.1.6. 鉴别器...
基本的finder生成器(Basic finder generator) 15.2.4. 基于Velocity的渲染器/生成器(Velocity based renderer/generator) 15.3. 映射文件生成器(Mapping File Generation) 15.3.1. 运行此工具 16. ...
基本的finder生成器(Basic finder generator) 15.2.4. 基于Velocity的渲染器/生成器(Velocity based renderer/generator) 15.3. 映射文件生成器(Mapping File Generation) 15.3.1. 运行此工具 16. ...
6. 对象/关系数据库映射基础(Basic O/R Mapping) 6.1. 映射定义(Mapping declaration) 6.1.1. Doctype 6.1.2. hibernate-mapping 6.1.3. class 6.1.4. id 6.1.4.1. Generator 6.1.4.2. 高/低位算法(Hi/Lo ...
3.3. JDBC连接 3.4. 可选的配置属性 3.4.1. SQL方言 3.4.2. 外连接抓取(Outer Join Fetching) 3.4.3. 二进制流 (Binary Streams) 3.4.4. 二级缓存与查询缓存 3.4.5. 查询语言中的替换 3.4.6. Hibernate的统计...
3.3. JDBC连接 3.4. 可选的配置属性 3.4.1. SQL方言 3.4.2. 外连接抓取(Outer Join Fetching) 3.4.3. 二进制流 (Binary Streams) 3.4.4. 二级缓存与查询缓存 3.4.5. 查询语言中的替换 3.4.6. Hibernate的统计...
6. 对象/关系数据库映射基础(Basic O/R Mapping) 6.1. 映射定义(Mapping declaration) 6.1.1. Doctype 6.1.2. hibernate-mapping 6.1.3. class 6.1.4. id 6.1.4.1. Generator 6.1.4.2. 高/低位算法(Hi/...