datasource

How to set a role in DataSource from Spring

谁说我不能喝 提交于 2019-12-06 14:50:34
问题 I have to use a default Role so that after the datasource has been defined and connected that role will allow me to use select statements. I know its little weird but I have to do it due to security concerns. So here is the code in my Spring's applicationContext.xml: <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="com.ibm.db2.jcc.DB2Driver" /> <property name="url" value="jdbc:db2://host_name:Port/DB_NAME

Spring boot preloading data from database in bean

◇◆丶佛笑我妖孽 提交于 2019-12-06 13:40:52
问题 I'm asking for elements that have a recursive relationship in one table: child id | parent id 1 | null 2 | 1 3 | 1 4 | 2 And so on...To ask for this whole datastructure it takes about 10 secondsAt the moment I can't redesign this table because it cost too much time (for more information: Spring Repository performance issues with recursive ORM Class) Now, I am thinking about preloading all data during spring startup in a bean, so that the client "communicates" with the bean and I update the

Created Parameterized query not showing in datasource visual studio 10 and access

空扰寡人 提交于 2019-12-06 12:56:06
I'm trying to replicate northwind database but when I created parameter query vw_CustomerOrderYear , the query is not showing in my datasource. I do not know what I'm missing.. My parameter query vw_CustomerOrderYear is : PARAMETERS OrderYear Long; SELECT DISTINCT Customer.ID, Customer.Name, Customer.City, Customer.Country, Year([Order].OrderDate) AS OrderYear FROM Customer INNER JOIN [Order] ON Customer.ID=Order.CustomerId WHERE (((Year(Order.OrderDate))=[OrderYear])) Or ((([OrderYear]) Is Null)); How can I get this query under my SomeNameDataSet ? When you create a "parameter query" in the

JBoss AS 5 database connection pool re-connect routine for MS SQL Server

送分小仙女□ 提交于 2019-12-06 12:54:52
问题 I'd like to come up with the best approach for re-connecting to MS SQL Server when connection from JBoss AS 5 to DB is lost temporarily. For Oracle, I found this SO question: "Is there any way to have the JBoss connection pool reconnect to Oracle when connections go bad?" which says it uses an Oracle specific ping routine and utilizes the valid-connection-checker-class-name property described in JBoss' Configuring Datasources Wiki. What I'd like to avoid is to have another SQL run every time

Property 'dataSource' is required Error in java (Spring)

早过忘川 提交于 2019-12-06 12:24:35
I am developing an web application in Java (Spring) My java file is as, try { JdbcTemplate jt = new JdbcTemplate(dataSource); System.out.println("Connection ....."+jt.toString()); Connection conn; Statement st; conn =DriverManager.getConnection(jt.toString()); conn = (Connection) jt.getDataSource(); st=conn.createStatement(); System.out.println("Connection created....."+st); } catch (Exception e) { System.out.println("Error Found...."+ e.getMessage()); System.out.println("Strack Trace....."+e.getStackTrace()); } My spring-servlet.xml file is as, <bean id="dataSource" class="org.springframework

How to obtain JNDI data source for JPA/JTA DAO integration test?

假装没事ソ 提交于 2019-12-06 11:58:43
问题 I have a JPA application that has specified JTA transactions in persistence.xml. For whatever reason, I have found that when using JTA, you MUST specify a JNDI data source within persistence.xml as well. This is fine, unless you are trying to go integration testing outside a container and JNDI is not available. My questions are: a) is there anyway to inject a jdbc datasource into my JTA transaction manager? b) if not, how do a handle a JNDI lookup during integration testing? Edit: The error I

Each request from user call a new getConnection()?

半城伤御伤魂 提交于 2019-12-06 11:22:58
The database connection is get like below public Connection getDBConection(){ Context context = new InitialContext(); DataSource dataSource = (javax.sql.DataSource) context.lookup("java:myDataSource"); Connection conn = dataSource.getConnection(); } For a userA, is each database request should call getDBConnection() once; but no need to control all request use the same connection? That is, if userA has three database request, then userA should call getDBConnection() three times, and call Connection.closed() after used in each request? If the userA call getDBConnection() three times (that is,

Refresh DataSource using Spring+dbcp

℡╲_俬逩灬. 提交于 2019-12-06 11:07:46
I'm using Spring with DBCP and need to refresh my datasource when some configuration on operation environment changes, without restart all application. If I do it with no use of DBCP, I force this refresh closing current opened datasource in use and Start a new instance of DataSource. Using DBCP+Spring, I can't do that. Somebody knows if it is possible? I don't think there is such a support in plain DBCP, mostly because database connection properties are very rarely changing during the lifetime of the application. Also you will have to consider transition time, when some connections served by

ArgumentException when adding ComboBox column to DataGridView with same DataSource

自闭症网瘾萝莉.ら 提交于 2019-12-06 11:03:19
问题 I have a DataGridView with custom columns. But when I add a " DataGridViewComboBoxColumn " and give to it a list of my model class as DataSource then I had the following error: System.ArgumentException: DataGridViewComboBoxCell value is not valid. New EDIT: 4/9/2009 "More Details" I've a class called SmsPart has these properties: public class SmsPart { public int ID public SmsPart Parent public string Name // and more } I've method called " GetSmsParts " return " List<SmsPart> ". I want the

DataTextField in a ListBox is a combination of 2 fields

狂风中的少年 提交于 2019-12-06 10:44:05
I have a listbox containing Users. The datasource is an generic list of the type User (contains, id, firstname, lastname, ...). Now I want to use the id as datavalue (through dataValueField) and I want LastName + ' ' + Firstname as a DataTextField. Can anyone tell me how this is possible? I'm using C# (ASP.NET). The easiest way is to add a new property to the User class that contains the full name: public string FullName { get { return LastName + " " + FirstName; } } And bind the listbox to that. This has the advantage of centralising the logic behind how the full name is constructed, so you