datasource

how to bind datasource to List<Dictionary<string, string>>?

我是研究僧i 提交于 2019-12-05 18:20:47
I have a class that stores a list of dictionary entries. I want bind that to a datasource for gridview from codebehind. Code for dictionary type of , representing ErrorMessage and failed field. public partial class FailedFields { private Dictionary<string, string> Code_Error = new Dictionary<string, string>(); public void AddFailedField(string field, string message) { Code_Error.Add(field, message); } public Dictionary<string, string> GetFailedFields() { return Code_Error; } } Code for List of Dictionary entries. public partial class ErrorFieldsList { private static List<Order.FailedFields>

Adding datasource programmatically to JNDI context in embedded tomcat 7

萝らか妹 提交于 2019-12-05 18:16:21
I'm trying to register a new datasource before the server starts but on lookup execution I'm getting javax.naming.NameNotFoundException: Name [jdbc/db] is not bound in this Context. Unable to find [jdbc]. This is how I start tomcat: Tomcat tomcat = new Tomcat(); //... ContextResource resource = new ContextResource(); resource.setName("jdbc/db"); resource.setAuth("Container"); resource.setType("javax.sql.DataSource"); resource.setScope("Sharable"); resource.setProperty("driverClassName", "org.hsqldb.jdbc.JDBCDriver"); resource.setProperty("url", "jdbc:hsqldb:hsql://localhost:1234/mydb1");

Are there JNDI namespace conventions?

房东的猫 提交于 2019-12-05 17:57:56
I have downloaded JBoss EAP 6.1 and I am going to add a new data source. I must bind the data source to a JNDI name. By reading the JNDI name of the sample data source which is: java:jboss/datasources/ExampleDS I see that they have used datasources after java:jboss . Is this just a naming convention - that I am not able to find anywhere - or would it be fine using java:jboss/bananaboat/MyDS ?` Is it correct that the first part that is listed below - such as java:comp is the scope and the rest is just normal hierarchy organization? java:comp/ - The namespace is scoped to the current component

Creating XA DataSource to DB2 on JBoss

一曲冷凌霜 提交于 2019-12-05 17:13:28
I trying to configure an XA DB2 DataSource, xa-datasource (based on http://community.jboss.org/wiki/SetUpADB2Datasource ) using com.ibm.db2.jcc.DB2XADataSource class ( local-tx-datasource works using the com.ibm.db2.jcc.DB2Driver ). The target server is DB2 Connect V9.7 Actual xa-datasource config: <xa-datasource> <jndi-name>jdbc/DB2ServerDS</jndi-name> <use-java-context>false</use-java-context> <track-connection-by-tx>true</track-connection-by-tx> <xa-datasource-class>com.ibm.db2.jcc.DB2XADataSource</xa-datasource-class> <xa-datasource-property name="URL">jdbc:db2://db2server:50000/FINDB</xa

Getting null pointer exception @Resource annotation in tomcat 7

醉酒当歌 提交于 2019-12-05 16:07:23
Here is my Resource element in context.xml :: <Resource name="jdbc/myoracle" auth="Container" type="javax.sql.DataSource" driverClassName="oracle.jdbc.driver.OracleDriver" url="jdbc:oracle:thin:@localhost:1521:XE" username="hr" password="hr" maxActive="20" maxIdle="10" maxWait="-1"/> Here is my Resource reference in web.xml: <resource-ref> <description>Oracle Datasource</description> <res-ref-name>jdbc/myoracle</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref> I then use @Resource annotation in my code: @Resource(mappedName = "jdbc/myoracle

SpringBoot多数据源及MyBatis配置详解

自作多情 提交于 2019-12-05 15:38:10
前言 最近迫于项目需要,笔者踏上了springboot多数据源的配置之旅。之前笔者配置过spring的动态多数据源切换,当时使用的是JDBC Template。 目前项目中持久化框架使用是mybatis,经过分析后不难发现,多数据源配置需要解决两个问题,一个是由原先的spring经典方式切换到了springboot方式下,多数据源如何配置?有无太大变化?另一个是怎样将多数据源与mybatis的配置关联起来? 不妨先来看下,单数据源下mybatis如何配置的? 单数据源示例 首先要声明一点,项目只是依赖单个数据源时,如果你不介意springboot帮你做事的话,那么恭喜你,你省事儿了!你只需要在项目的属性文件中添加数据源的相关属性配置,springboot会“免费”提供给你一个数据源使用,默认采用的是 tomcat jdbc connection pool 。 当然你可以拒绝springboot的好意,如果你依赖第三方的连接池技术,你可以配置自己的数据源,那么springboot检测到你自己定义了DataSource后,就不会自动配置数据源了。 笔者不能拒绝springboot的好意,所以仅在项目的application.properties中添加了如下属性: spring.datasource.url=jdbc:mysql://localhost:3306/test spring

HikariCP pass Oracle custom type

为君一笑 提交于 2019-12-05 13:45:16
I switched to HikariCP from Oracle default datasource. There is a piece of code where I pass custom Oracle type to a stored parameter, and cast java.sql.Connection to oracle.jdbc.OracleConnection . try(OracleConnection connection = (OracleConnection) dbConnect.getConnection()) { try(CallableStatement callableStatement = connection.prepareCall("{? = call pkg_applications.add_application(?,?,?)}")) { callableStatement.registerOutParameter(1, Types.VARCHAR); callableStatement.setString(2, form.getPolicyNumber()); callableStatement.setString(3, form.getPolicyStart()); Object[][] uploads = new

Spring dataSource bean definition failing

倾然丶 夕夏残阳落幕 提交于 2019-12-05 12:49:56
I'm trying to use Spring's JdbcTemplate to simplify my DAOs in a Java web service that is deployed in Tomcat and connects to Postgres. I'm following Spring's documention , and I'm trying configure a DataSource in the application context file, as follows: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd

Executing SQL inserts during Grails application startup

依然范特西╮ 提交于 2019-12-05 11:10:50
I am in development phase, trying to use in-memory DB and load it with some data during Grails application start up. My question is, is there any way to write/configure SQL insert statements that can be executed during startup. You can do this in BootStrap.groovy. If you add a dependency injection for the dataSource bean you can use it with a groovy.sql.Sql instance to do inserts: import groovy.sql.Sql class BootStrap { def dataSource def init = { servletContext -> def sql = new Sql(dataSource) sql.executeUpdate( 'insert into some_table(foo, bar) values(?, ?)', ['x', 'y']) } } You would

AbstractRoutingDataSource doesn't change connection

主宰稳场 提交于 2019-12-05 10:01:16
I use AbstractRoutingDataSource to change data source dynamically and ThreadLocal to set up currentLookupKey. It works nice when I use only one data source per http request. I use JpaRepository @Component @Primary public class RoutingDataSource extends AbstractRoutingDataSource { @Autowired private DatabaseMap databaseMap; @Override public void afterPropertiesSet() { setTargetDataSources(databaseMap.getSourcesMap()); setDefaultTargetDataSource(databaseMap.getSourcesMap().get("DEFAULT")); super.afterPropertiesSet(); } @Override protected Object determineCurrentLookupKey() { return