derby

初探Apache derby

佐手、 提交于 2019-12-01 08:22:00
一. Derby能提供什么? Derby是一个基于Java和SQL ,开源的 RDBMS 。完全使用Java实现,他为用户提供了一个小巧的基于标准的数据库引擎,他可以嵌入到任Java解决方案中,他确保数据完成并提供复杂的事务支持。Derby的数据完全存储在磁盘上,他是一可携带的数据库,你可以将他从一台机器拷贝到另一台机器。更多信息请访问 http://db.apache.org/derby 二. Derby如何开始? Derby的两种模式:内嵌模式【他和你应用程序在同一个JVM中,不需要单独配置和你的应用程序有相同的生命周期】、服务模式【运行在独立的JVM中,需要网络配置这点类似于Mysql等数据库】 系统要求:Derby 使用 Java 开发依赖于JDK ,要求JDK版本 1.5+ 。查看版本可以使用命令 java -version 下载安装Derby : 下载地址: http://db.apache.org/derby/derby_downloads.html 设置环境变量: DERBY_HOME 变量值=解压的目录,目录的结构就不解释了。 设置Path 和 CLASSPATH : 在 Path中增加 %DERBY_HOME%\bin 、在 CLASSPATH 中增加 %DERBY_HOME%\lib 三. 有哪些工具?怎样用? ij 是Derby交互式JDBC脚本工具

Problems with escaping table and field names in Derby and Hsqldb

◇◆丶佛笑我妖孽 提交于 2019-12-01 06:56:29
I'm having a problem with my ORMLite package . When I generate the schema for a table, I thought it would be a good practice to escape all entity names. This would protect some Java class or field name from being a SQL reserved word: CREATE TABLE "footable" ("stuff" VARCHAR(255)) I'm now adding "raw" query support so that ORMLite can help users perform their own queries. However, I find that with Derby and Hsqldb, the entity names cannot be used without escaping. For example, the following query: SELECT * FROM footable generates the following errors: Derby: ERROR 42X05: Table/View 'FOOTABLE'

Hibernate + Derby: Comparisons between 'BOOLEAN' and 'INTEGER' are not supported

别等时光非礼了梦想. 提交于 2019-12-01 06:23:09
I have a problem with querying Derby database. I am using Hibernate with JPA. Problem is related (probably) to boolean columns. Each query ends with error: org.hibernate.exception.SQLGrammarException: Comparisons between 'BOOLEAN' and 'INTEGER' are not supported. Types must be comparable. String types must also have matching collation. If collation does not match, a possible solution is to cast operands to force them to the default collation (e.g. SELECT tablename FROM sys.systables WHERE CAST(tablename AS VARCHAR(128)) = 'T1') Below you may find sample code and configuration. Samples are

Starting Derby Programmatically

北慕城南 提交于 2019-12-01 05:28:39
Please have a look at the following code DataBaseConnector.java import java.sql.*; import javax.swing.*; public class DataBaseConnector { private Connection con; public DataBaseConnector() { } private boolean createConnection() { try { Class.forName("org.apache.derby.jdbc.EmbeddedDriver"); con = DriverManager.getConnection("jdbc:derby://localhost:1527/contact;create=true","yohanrw","knight"); } catch(Exception e) { System.out.println("Error getConnection"); e.printStackTrace(); JOptionPane.showMessageDialog(null,e.getLocalizedMessage()); return false; } return true; } private void

Problems with escaping table and field names in Derby and Hsqldb

点点圈 提交于 2019-12-01 05:08:37
问题 I'm having a problem with my ORMLite package. When I generate the schema for a table, I thought it would be a good practice to escape all entity names. This would protect some Java class or field name from being a SQL reserved word: CREATE TABLE "footable" ("stuff" VARCHAR(255)) I'm now adding "raw" query support so that ORMLite can help users perform their own queries. However, I find that with Derby and Hsqldb, the entity names cannot be used without escaping. For example, the following

java derby database batch load from CSV

爷,独闯天下 提交于 2019-12-01 04:32:40
问题 Does Derby have any capabilities from performing a batch insert of data from a CSV? The best I could come up with was to read in the file line by line and create a batch SQL update statement and run that. For 1 million rows that took between 30-40 minutes, as compared with using mySQL's LOAD statement to load from a CSV file which took 2-3 seconds for the same data 回答1: syscs_util.syscs_import_table will do what you want. Here's the docs: http://db.apache.org/derby/docs/10.5/tools

Starting Derby Programmatically

青春壹個敷衍的年華 提交于 2019-12-01 03:04:28
问题 Please have a look at the following code DataBaseConnector.java import java.sql.*; import javax.swing.*; public class DataBaseConnector { private Connection con; public DataBaseConnector() { } private boolean createConnection() { try { Class.forName("org.apache.derby.jdbc.EmbeddedDriver"); con = DriverManager.getConnection("jdbc:derby://localhost:1527/contact;create=true","yohanrw","knight"); } catch(Exception e) { System.out.println("Error getConnection"); e.printStackTrace(); JOptionPane

Converting from String to Clob using setString() not working

ぐ巨炮叔叔 提交于 2019-12-01 02:25:47
问题 I am trying to convert a String into a Clob to store in a database. I have the following code: Clob clob = connection.createClob(); System.out.println("clob before setting: " + clob); clob.setString(1,"Test string" ); System.out.println("clob after setting: " + clob); System.out.println("clob back to string: " + clob.toString()); When I run this the Clob is not being set, the output is as follows: clob before setting: org.apache.derby.impl.jdbc.EmbedClob@1f5483e clob after setting: org.apache

SBT test does not work for spark test

时光怂恿深爱的人放手 提交于 2019-12-01 01:35:07
问题 I have a simple spark function to test DF windowing: import org.apache.spark.sql.{DataFrame, SparkSession} object ScratchPad { def main(args: Array[String]): Unit = { val spark = SparkSession.builder().master("local[*]").getOrCreate() spark.sparkContext.setLogLevel("ERROR") get_data_frame(spark).show() } def get_data_frame(spark: SparkSession): DataFrame = { import spark.sqlContext.implicits._ val hr = spark.sparkContext.parallelize(List( ("Steinbeck", "Sales", 100), ("Woolf", "IT", 99), (

Why do I get java.sql.SQLException: ResultSet not open. Operation 'next' not permitted. java derby database?

对着背影说爱祢 提交于 2019-12-01 00:32:47
I'm getting this error: java.sql.SQLException: ResultSet not open. Operation 'next' not permitted. Verify that autocommit is off. when I'm trying to create instances from a db. Current code: try { connection.setAutoCommit(false); stmt = connection.createStatement(); results = stmt.executeQuery("SELECT * from animalTable"); int AnimalCat = -1; System.out.print(connection.getAutoCommit()); //getting error on line below while(results.next()) { int ID = results.getInt(1); int Age = results.getInt(2); String Name = results.getString(3); String AType = results.getString(4); String Breed = results