h2

h2 mixed mode connection problem

本小妞迷上赌 提交于 2019-11-30 17:31:14
问题 I start h2 database in a servlet context listener: public void contextInitialized(ServletContextEvent sce) { org.h2.Driver.load(); String apprealPath = sce.getServletContext().getRealPath("\\"); String h2Url = "jdbc:h2:file:" + apprealPath + "DB\\cdb;AUTO_SERVER=true"; LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); StatusPrinter.print(lc); logger.debug("h2 url : " + h2Url); try { conn = DriverManager.getConnection(h2Url, "sa", "sa"); } catch (SQLException e) { e

How to start H2 TCP server on Spring Boot application startup?

半世苍凉 提交于 2019-11-30 17:00:30
问题 I'm able to start the H2 TCP server (database in a file) when running app as Spring Boot app by adding following line into the SpringBootServletInitializer main method: @SpringBootApplication public class NatiaApplication extends SpringBootServletInitializer { public static void main(String[] args) { Server.createTcpServer().start(); SpringApplication.run(NatiaApplication.class, args); } } But if I run the WAR file on Tomcat it doesn't work because the main method is not called. Is there a

java ClassNotFoundException for org.h2.Driver

瘦欲@ 提交于 2019-11-30 16:57:22
I am trying to use H2 to connect to a database in Java (using Eclipse as the IDE). The sample does (below) throws a ClassNotFoundException . The thing is, I did add the h2 jar file to the system CLASSPATH. I have even checked it's there several times via printenv in the console. Am I omitting a step? CODE: import java.sql.*; public class Program { /** * @param args */ public static void main(String[] args) throws Exception{ try{ System.out.println("hello, world!"); Class.forName("org.h2.Driver"); Connection conn = DriverManager.getConnection("jdbc:h2:~/testdb", "sa", ""); // add application

Is SQLite the most appropriate thing to use for an embedded database? [duplicate]

安稳与你 提交于 2019-11-30 15:53:31
This question already has an answer here: Java and SQLite [closed] 10 answers I need to build a Java application that I will install on a Linux server. When people will install they just would need to install this application, launch it, and nothing more. But we have some data to save. I said no to MySQL, because it needs a server. I said no to XML because there will be really a lot of data to save and manipulate. So I'm looking at SQLite which is the best I think. Indeed (stop me if i'm wrong), SQLite doesn't need any server? (just install the final application and SQLite works fine in my

HIBERNATE - JPA2 - H2 - Querying @ElementCollections HashMap by key

家住魔仙堡 提交于 2019-11-30 15:51:06
I'm using hibernate-entitymanager 3.6.4.Final and h2 database 1.3.155 I'm using the H2Dialect. I'm having trouble filtering records by elements in an @ElementCollection. Here is my entity @Entity public class Item { @Id @GeneratedValue(strategy = GenerationType.AUTO) @MapKeyColumn(name="name", length=50) @Column(name="value", length=100) protected Map<String, String> attributes; /* etc. */ } Here is my query : Item item = em.createQuery("FROM Item i JOIN i.attributes a WHERE KEY(a)='myAttrName'").getSingleResult(); Here is the error message : 4971 [main] WARN org.hibernate.util

Connect remotely to an H2 Database using a Java Application

北城余情 提交于 2019-11-30 15:34:23
I'm having the following problem: When I try to createTcpServer with my external IP address (the PC's IP and not my local IP = the one we see as an output after running ipconfig in cmd.exe) the following error occurs: Error with Server: Exception opening port "9092" (port may be in use), cause: "java.net.BindException: Cannot assign requested address: JVM_Bind" [90061-169] However, the port is not in use. I've checked that using netstat -a -n . I have enabled my external IP and I have disabled the firewall from the router. My external IP can now be pinged. Please help me. Update: Here is my

javascript-案例 简易日历(无this.index)

送分小仙女□ 提交于 2019-11-30 13:22:05
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> <style type="text/css"> * { padding: 0; margin: 0; } li { list-style: none; } body { background: #f6f9fc; font-family: arial; } .calendar { width: 210px; margin: 0 auto; padding: 10px 10px 20px 20px; background: #eae9e9; } .calendar ul { width: 210px; overflow: hidden; padding-bottom: 10px; } .calendar li { float: left; width: 58px; height: 54px; margin: 10px 10px 0 0; border: 1px

对话实录|华为云.通信云服务激活无限商业潜力

瘦欲@ 提交于 2019-11-30 12:58:01
在LiveVideoStackCon2019深圳音视频技术大会前夕,我们邀请到了华为云核心网产品线,高级架构师左俊老师接受采访,采访中左俊老师从自身十五年的架构师经验出发浅谈了自己对于近几年音视频通话技术的发展,并从覆盖场景、数据安全和视频质量审核等方面介绍了华为云通信云服务的优势。 文 / 左俊 整理 / LiveVideoStack LiveVideoStack:左俊你好,能否先向LiveVideoStack的读者介绍下自己,以及你目前主要的工作以及关注的技术方向? 左俊: 我目前主要的负责是华为云.通信云服务整个解决方案的架构和技术。华为云.通信云服务目前包括如下四个服务:视频通话服务、隐私保护通话服务、语音通话服务、短信服务。当下,我主要关注的有以下两点: 音视频方案中的效果及质量问题,这个是整个音视频解决方案最为基础的部分,华为在运营商市场实时音视频的成功实践,为解决互联网视频通话的效果和质量问题,提供有效的借鉴和支撑,这也是华为云.视频通话服务快速孵化的基础。 解决方案中的安全韧性及合法合规问题,虽然这不是基础业务的一部分,但是这个是客户能够获取持久保障的前提,华为很看重这一块,也能够保证向客户持续地提供可靠可信的服务。 此外还有系统的开放性灵活性,成本管理,客户的个性化服务等,也都是整个解决方案中不可或缺的一环。 LiveVideoStack

HashMap 和 Hashtable 的 6 个区别,最后一个没几个人知道!

痴心易碎 提交于 2019-11-30 11:52:07
HashMap 和 Hashtable 是 Java 开发程序员必须要掌握的,也是在各种 Java 面试场合中必须会问到的。 但你对这两者的区别了解有多少呢? 现在,栈长我给大家总结一下,或许有你不明朗的地方,在栈长的指点下都会拨开迷雾见晴天。 1、线程安全 Hashtable 是线程安全的,HashMap 不是线程安全的。 为什么说 HashTable 是线程安全的? 来看下 Hashtable 的源码,Hashtable 所有的元素操作都是 synchronized 修饰的,而 HashMap 并没有。 public synchronized V put(K key, V value); public synchronized V get(Object key); ... 2、性能优劣 既然 Hashtable 是线程安全的,每个方法都要阻塞其他线程,所以 Hashtable 性能较差,HashMap 性能较好,使用更广。 如果要线程安全又要保证性能,建议使用 JUC 包下的 ConcurrentHashMap。 3、NULL Hashtable 是不允许键或值为 null 的,HashMap 的键值则都可以为 null。 那么问题来了,为什么 Hashtable 是不允许 KEY 和 VALUE 为 null, 而 HashMap 则可以? Hashtable put

Saving in-memory H2 database to disk

删除回忆录丶 提交于 2019-11-30 11:25:30
How can I save/load full embedded h2 in-memory database to some file or directory in binary mode for faster loading. I want to use this for caching data so I don't have to run all the lines of create table/insert clauses every time. Thomas Mueller Instead of using an in-memory database, you could use a regular (persisted) database. You can still use in-memory tables even then (create memory table). The easiest way to persist a completely in-memory database to disk is to use the SCRIPT TO 'fileName' SQL statement. This will create an SQL script. The data is stored in text form, which doesn't