About the MariaDB Java Client

2023-11-14

https://kb.askmonty.org/en/about-the-mariadb-java-client/


The MariaDB Client Library for Java Applications is used to connect applications developed in Java to MariaDB and MySQL databases using the standard JDBC API. The client library is LGPL licensed.

Introduction

The MariaDB Client Library for Java Applications is a Type 4 JDBC driver. It was developed specifically as a lightweight JDBC connector for use with MySQL and MariaDB database servers. It's originally based on the Drizzle JDBC code, and with a lot of additions and bug fixes.

Obtaining the driver

The driver (jar and source code) can be downloaded from https://downloads.mariadb.org/client-java/

Installing the driver

Installation is as simple as placing the .jar file in your classpath.

Requirements

  • Java 6
  • A MariaDB or MySQL Server
  • maven (only if you want build from source)

Source code

The source code is available on Launchpad: https://launchpad.net/mariadb-java-client. Development version can be obtained using

bzr branch lp:mariadb-java-client

License

GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

Building and testing the driver

The section deals with building the connector from source and testing it. If you have downloaded a ready built connector, in a jar file, then this section may be skipped.

MariaDB Client Library for Java Applications uses maven for build. You first need to ensure you have both java and maven installed on your server before you can build the driver.

To run the unit test, you'll need a MariaDB or MySQL server running on localhost and a database called 'test ', and user root with empty password

$ bzr branch lp:mariadb-java-client #  Or, unpack the source distribution tarball
$ cd mariadb-java-client
# For the unit test run, start local mysqld mysqld, 
# ensure that user root with empty password can login
$ mvn package
# If you want to build without running unit  tests, use
# mvn -Dmaven.test.skip=true package

After that , you should have JDBC jar mariadb-java-client-x.y.z.jar in the 'target' subdirectory

Installing the driver

Installation of the client library is very simple, the jar file should be saved in an appropriate place for your application and the classpath of your application altered to include the MariaDB Client Library for Java Applications rather than your current connector.

Using the driver

The following subsections show the formatting of JDBC connection strings for MariaDB, MySQL database servers. Additionally, sample code is provided that demonstrates how to connect to one of these servers and create a table.

Driver Manager

Applications designed to use the driver manager to locate the entry point need no further configuration, the MariaDB Client Library for Java Applications will automatically be loaded and used in the way any previous MySQL driver would have been.

Driver Class

The driver class provided by the MariaDB Client Library for Java Applications is org.mariadb.jdbc.Driver.

Connection strings

Format of the JDBC connection string is

jdbc:mysql:<host>:<port>/<database>?<key1>=<value1>&<key2>=<value2>...

Optional URL parameters

General remark: Unknown options accepted and are silently ignored.

Following options are currently supported.

key description supported since version
user Database user name 1.0.0
password Password of database user 1.0.0
fastConnect If set, skips check for sql_mode, assumes NO_BACKSLASH_ESCAPES is *not* set 1.0.0
useFractionalSeconds Correctly handle subsecond precision in timestamps (feature available with MariaDB 5.3 and later).May confuse 3rd party components (Hibernated) 1.0.0
allowMultiQueries Allows multiple statements in single executeQuery 1.0.0
dumpQueriesOnException If set to 'true', exception thrown during query execution contain query string 1.1.0
useCompression allow compression in MySQL Protocol 1.0.0
useSSL Force SSL on connection (client certificates are not yet supported) 1.1.0
socketFactory to use custom socket factory, set it to full name of the class that implements javax.net.SocketFactory 1.0.0
tcpNoDelay Sets corresponding option on the connection socket 1.0.0
tcpKeepAlive Sets corresponding option on the connection socket 1.0.0
tcpRcvBuf set buffer size for TCP buffer (SO_RCVBUF) 1.0.0
tcpSndBuf set buffer size for TCP buffer (SO_SNDBUF) 1.0.0
tinyInt1isBit Datatype mapping flag, handle MySQL Tiny as BIT(boolean) 1.0.0
yearIsDateType Year is date type, rather than numerical 1.0.0
sessionVariables <var>=<value> pairs separated by comma, mysql session variables, set upon establishing successfull connection 1.1.0

JDBC API Implementation Notes

Streaming result sets

By default, Statement.executeQuery() will read full result set from server before returning. With large result sets, this will require large amounts of memory. Better behavior in this case would be reading row-by-row, with ResultSet.next(), so called "streaming" feature. It is activated using  ResultSet.setFetchSize(Integer.MIN_VALUE)

Prepared statements

The driver only uses text protocol to communicate with the database. Prepared statements (parameter substitution) is handled by the driver, on the client side.

CallableStatement

Callable statement implementation won't need to access stored procedure metadata ( mysql.proc) table, if both of following is true

  • CallableStatement.getMetadata() is not used
  • Parameters are accessed by index, not by name

When possible, following 2 rules above provides both better speed and eliminates concerns about SELECT privileges on mysql.proc table

Optional JDBC classes

Following optional interfaces are implemented by the org.mariadb.jdbc.MySQLDataSource class : javax.sql.DataSource, javax.sql.ConnectionPoolDataSource, javax.sql.XADataSource

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

About the MariaDB Java Client 的相关文章

  • 长 IN 子句是代码异味吗?

    简单的问题 想知道长 IN 子句是否有代码味道 我真的不知道如何证明它的合理性 除了我认为的味道之外 我无法解释为什么它有味道 select name code capital population flower bird from us
  • PHP - 解析具有固定列宽的文本文件

    我是 PHP 和 Laravel 的新手 我需要打开文件并解析内容以将它们传递到数据库 文本文件具有固定的列宽 它没有分隔符或标题 我认为使用子字符串并将每个子字符串分配给变量将是正确的方法 但我仍在学习该语言的过程中 我不知道如何实现这一
  • 使用git在测试和生产环境之间同步数据库

    我正在尝试在 php mysql 应用程序的开发过程中实现 git 到目前为止 我已经设置了 git repos 并且我们正在使用本地计算机进行测试 并且我们成功地将其用于文件 但我真的不知道如何处理数据库 服务器上有一个 cron 脚本
  • 如何打开sqlite数据库并将其转换为pandas dataframe

    我已经下载了一些数据作为 sqlite 数据库 data db 我想在 python 中打开这个数据库 然后将其转换为 pandas 数据框 这是到目前为止我所做的 import sqlite3 import pandas dat sqli
  • Firestore 每秒向一个集合写入 500 多次以上

    Firestore 的限制为每秒 500 次写入 to 一个集合 其中文档包含顺序值 索引字段 https cloud google com firestore quotas writes and transactions https cl
  • DB2连接授权失败原因:Java不支持安全机制

    我正在尝试使用 DB2JDBC Type4 驱动程序配置 DB2 连接 但我收到这个错误 线程 main 中的异常 com ibm db2 jcc am SqlInvalidAuthorizationSpecException jcc t4
  • Elasticsearch 聚合过滤器

    因为我在谷歌上找不到任何东西 是否可以在elasticsearch中过滤聚合 我正在考虑这样的事情 获取 SOME object X gt 100 的所有对象 提前致谢 编辑 样本数据 我有以下文档结构 docKey 1 value 2 d
  • 通过 JDBC 将“daterange”字段值插入 PostgreSQL 表

    我在 PostgreSQL 9 3 有一个表日期范围 http www postgresql org docs 9 3 static rangetypes html字段类型 我可以像使用 JDBC 的字符串一样选择此字段 但无法将其插入表中
  • 社交应用程序的数据库设计和优化注意事项

    通常的情况 我有一个简单的应用程序 允许人们上传照片并关注其他人 因此 每个用户都会有类似 墙 或 活动源 的东西 他或她可以在其中看到他 她的朋友 他或她关注的人 上传的最新照片 大多数功能都很容易实现 然而 当涉及到这个历史活动源时 由
  • 如何在 PostgreSQL 中将数据库从一台服务器移动到另一台服务器?

    我正在尝试将数据库从旧服务器移动到新服务器 任何帮助 将不胜感激 Just pipe http www postgresql org docs current interactive migration html从旧服务器转储到新服务器 p
  • 如何在 Visual Studio 中更改 Azure 数据库表的列顺序

    我整个下午都在寻找在 MS Visual Studio 2022 中重新排序 Azure 数据库表列的方法 没有运气 在其他应用程序中 可以通过拖动或剪切和粘贴轻松重新排列列 这里无能为力 此时 我什至不确定可以在 VS 中移动列 我只对
  • 如何在不运行 PostgreSQL 服务器的情况下初始化 PostgreSQL 数据库

    在初始化脚本中 我想初始化 PostgreSQL 目录 但在此阶段不需要 也不希望 正在运行的 PostgreSQL 服务器 如果我只是创建集群 作为用户postgres initdb D 但是 我还需要创建 PostgreSQL 角色 创
  • 在 SQL 数据库中存储“列表”的最正确方法是什么?

    因此 我读了很多关于如何将多个值存储到一个列中是一个坏主意 并且违反了数据标准化的第一条规则 令人惊讶的是 这不是 不要谈论数据标准化 所以我需要一些帮助 目前我正在为我工 作的地方设计一个 ASP NET 网页 我想根据此人所属的 Act
  • 使用Python将文本文件导入Access 2003数据库

    我正在尝试使用我正在开发的 Python 3 4 应用程序将管道分隔的文本文件导入到具有现有表的 Access 数据库中 但遇到了一些麻烦 该应用程序将用于导入不同的文本文件 因此我使用条目小部件来写入文件名 并且我希望将输入的文件的内容加
  • java ResultSet,使用MAX sql函数

    你好 这就是我想要的 我连接到数据库并检索 UniqueId 列的最大元素 并将其分配给名为 maxID 的整数变量 这是我的方法 int maxID 0 Statement s2 con createStatement s2 execut
  • 如何停止在 mongodb 集合中插入重复文档

    让我们有一个MongoDB包含三个文档的集合 db collection find id user A title Physics Bank Bank A id user A title Chemistry Bank Bank B id u
  • 有没有办法阻止 SQL Express 2008 空闲?

    我使用 SQL Express 2008 作为 Web 应用程序的后端 问题是 Web 应用程序是在工作时间使用的 因此有时在午餐或休息时间 如果 20 分钟内没有用户登录 SQL Express 将进入空闲状态模式并释放其缓存 我知道这一
  • Android Realm.io:行/对象不再有效

    这是我的删除功能 它确实找到了workday1 object public static void delete Context context Workday workday Realm realm getRealm context re
  • 我应该用不可变或可变的数据结构来表示数据库数据吗?

    我目前正在使用 Scala 进行编程 但我想这适用于任何函数式编程语言 或者更确切地说 任何建议不变性并可以与数据库交互的编程语言 当我从数据库中获取数据时 我将其映射到模型数据结构 在函数式编程中 数据结构往往是不可变的 但是数据库中的数
  • 数据库字段中的逗号分隔值

    我有一个产品表 该表中的每一行对应一个产品 并由唯一的 ID 标识 现在 每个产品都可以有多个与该产品关联的 代码 例如 Id Code 0001 IN ON ME OH 0002 ON VI AC ZO 0003 QA PS OO ME

随机推荐

  • C#程序演示Console.Write()和Console.WriteLine()的示例

    Console Write and Console WriteLine methods are used to print the text values on the Console Console Write prints only t
  • Postgresql查询每组的前N条记录

    Postgresql以指定字段分组后 查询每组的前N条记录 主函数 ROW NUMBER OVER PARTITION BY 省份名称 地市名称 ORDER BY arpu desc dou DESC AS row id 在原有数据表的基础
  • ORA-01157报错"cannot identify/lock data file"

    sqlplus以管理员方式接入数据库 启动时出现报错 如下 gt sqlplus as sysdba SQL gt startup ORA 01157 cannot identify lock data file 8 see DBWR tr
  • 数据结构:数组模拟队列

    实现一个队列 队列初始为空 支持四种操作 push x 向队尾插入一个数 x pop 从队头弹出一个数 empty 判断队列是否为空 query 查询队头元素 数组模拟队列 队列 先进先出 include
  • mysql注入语句说明

    判断闭合id 1 页面正常 id 1 页面不正常 id 1 页面恢复正常说明闭合是 id 1 页面正常 id 1 页面不正常 id 1 页面还是不正常说明闭合不是 如果这时id 1 页面恢复正常 说明闭合是 id 1 and 1 1id 1
  • 为何实现不了定时器DMA Burst传输?

    有人使用STM32F4系列开发产品 程序运行过程中需要不时地对外输出一串驱动脉冲 并要求这几串脉冲的频率可变 占空比固定 他想到使用基于STM32定时器的DMA BURST传输 具体点说 他期望不时地通过TIM3的CH1输出一串频率可变 占
  • 二叉树的基本概念及性质

    文章目录 一 基本概念 二 二叉树的种类 二叉树 满二叉树 完全二叉树 二叉搜索树 平衡二叉搜索树 三 二叉树的性质 性质一 性质二 性质三 性质四 性质五 一 基本概念 树是 n 个结点的有限集 在任意一颗非空树中 1 有且仅有一个特定的
  • window修改本地域名

    C Windows System32 drivers etc 127 0 0 1 bbs itcast com 127 0 0 1 mail itcast com 127 0 0 1 cas itcast cn 127 0 0 1 www
  • 简单理解promise

    promise是ES6为我们提供解决 回调地狱 的一种方法 能让代码的可读性更高 先看一个最简单的例子 new Promise function resolve reject executor 首先我们先new一个 Promise 对象时
  • 显示搜索dota2协调服务器,搜索dota2游戏协调服务器中【操作方式】

    喜欢使用电脑的小伙伴们一般都会遇到win7系统搜索dota2游戏协调服务器中的问题 突然遇到win7系统搜索dota2游戏协调服务器中的问题就不知道该怎么办了 其实win7系统搜索dota2游戏协调服务器中的解决方法非常简单 按照 1 DO
  • Hive 任务限制同时运行的任务数量的配置

    Hive任务的并发控制 指同时运行的 container 的数量 防止先提交的任务占用全部的队列资源 导致后来提交的任务无法申请到足够的资源 Hive 任务的并发控制 和使用的引擎相关 MapReduce MR 引擎 Map 任务 mr 引
  • 微信收钱的盒子服务器老是断开,微信文件已过期或被清理的终极解决办法

    工作中总是有同事习惯用微信传文件 当我们沿着微信对话爬楼找历史文件时 总会收到让人绝望的提醒 文件已过期或被清理 这里有个抢救办法 你不妨一试 如果文件当时是通过电脑发的 可以在 此电脑 文档 WeChat File 中找找 如果没有就真是
  • 基础数据结构之单循环链表

    文章目录 一 补充上节课的知识点 单链表和顺序表的区别 顺序表和单链表的使用场景分析 二 认识单循环链表 1 将单循环链表的增删改查用画图方式展现出来 2 用代码实现单循环链表 一 补充上节课的知识点 单链表和顺序表的区别 顺序表和单链表的
  • Qt中以qRegister开头的几个函数的用法说明

    目录 1 前言 2 qRegisterMetaTypeStreamOperators 2 1 函数功能简述 2 2 用法举例1 3 qRegisterMetaType 1 前言 Qt通过qRegister开头的函数和Q DECLARE开头的
  • 深度学习知识点一

    1 说说卷积和全连接网络的区别 2 什么是感受野呢 3 深度学习的 深度 是不是一昧的增加深度就好了吗 网络是否越深越好 4 减少过拟合的手段 5 简单的说一下YOLO V1 6 MobileNet 用到的模型压缩手段是什么 7 简单的说一
  • Java集合面试题 52道

    集合容器概述 什么是集合 集合就是一个放数据的容器 准确的说是放数据对象引用的容器 集合类存放的都是对象的引用 而不是对象的本身 集合类型主要有3种 set 集 list 列表 和map 映射 集合的特点 集合的特点主要有如下两点 集合用于
  • C51单片机--IO口应用

    流水灯 文章目录 流水灯 前言 一 D1到D8依次点亮 二 读入开关K1 K4的状态 按下对应开关 控制相应D1 D4灯亮 三 流水灯 功能 LED从左边起D1 D3亮 并闪烁3次 然后是D2 D4亮 并闪烁3次 然后D3 D5亮 闪烁3次
  • SQL面试题之区间合并问题

    目录 0 需求 1 数据准备 2 数据分析 2 小结 0 需求 给定多个时间段 每个时间段分为开始时间 结束时间 将相互重叠的多个时间段合并为一个区间 数据 id 开始时间 结束时间 1 12 15 2 57 58 3 29 32 4 30
  • JDK 监控和故障处理工具

    JDK 监控和故障处理工具总结 JDK 命令行工具 这些命令在 JDK 安装目录下的 bin 目录下 jps JVM Process Status 类似 UNIX 的 ps 命令 用户查看所有 Java 进程的启动类 传入参数和 Java
  • About the MariaDB Java Client

    https kb askmonty org en about the mariadb java client The MariaDB Client Library for Java Applications is used to conne