FAQ Database Discussion Community


Re-directing linked tables

access-vba,ms-access-2010,dao
I am having what I believe to be a syntax issue with the third line of code below where I am trying to source a table located in a back-end database in a directory differing than the front end. Run time error is 3055 - file not valid Function linkToUnc()...

Violation of DAO pattern. What to do?

java,dao
I need to generate and then perform a complex sql-query which is going to access multiple databases to create some general report. This implies that the query's not related to a specific DAO object. So where should I put the logic of executing such a query and returning result as...

DAO Design Pattern vs DBUnit Code

java,design-patterns,junit,dao,dbunit
I am not sure if my DAO or DBUnit Test needs some refactoring. Can somebody please guide on the situation that I am facing? I have a DAO that gets some data from the DB by getting a Connection object and then it closes all the resources(ResultSet, Statement and Connection)....

JSF Controller, Service and DAO

jsf,java-ee,jpa,ejb,dao
I'm trying to get used to how JSF works with regards to accessing data (coming from a spring background) I'm creating a simple example that maintains a list of users, I have something like <h:dataTable value="#{userListController.userList}" var="u"> <h:column>#{u.userId}</h:column> <h:column>#{u.userName}</h:column> </h:dataTable> Then the "controller" has something like @Named(value = "userListController") @SessionScoped...

Can connection passing through constructor in DAO pattern be unsafe in any case?

java,design-patterns,dao
I am using DAO pattern. In my case the DAO does not open or close connection; instead connection is passed to it through constructor; it uses that connection to perform its job. Can connection passing through constructor to DAO layer be unsafe in any case? If yes please tell me...

Creating multiple databases or schemas with Spring JDBC

mysql,spring,dao,spring-jdbc
i'm currently working on a Spring MVC project where i need multiple databases, one for each person that signs up(i know it's gonna be heavy but the number is limited). So after a person logs in, he should have access only to his database, but how do i do that...

Autowired class is null

java,spring,dao,mybatis
SUMMARY I'm building a spring-mvc web application and trying to use Mybatis and DAO for data access. I configured Mybatis successfully and I was able to fetch expected data from Mysql server. But a problem occured when I tried to use DAO with Mybatis. ERROR As you could see below,...

Arquillian Test POST_MODULE: Failed to process phase POST_MODULE of deployment <>.jar

java-ee,jpa,jboss7.x,dao,jboss-arquillian
I have created few test from my EJBs in Arquillian. 2 tests passed so far. Unfortunately 3rd test fails with weird information which I have trouble to track. 13:16:51,206 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC00001: Failed to start service jboss.deployment.unit."test4.jar".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.unit."test4.jar".POST_MODULE: Failed to process phase POST_MODULE...

Issue when using a DAO handle when the database closes unexpectedly

vba,access-vba,ms-access-2010,dao
I am using a DAO handle (represented in the below code) to improve the speed and performance of my Access database which is found on a shared network and is quite slow. The below code was offered to me by an expert to help the database improve it's speed and...

What is the improvement of using DAO in Java SE?

java,testing,design,dao
My project manager wants me to use DAO/DTO objects to access and retrieve data from database. Project is written in Java SE without using any framework or ORM. His arguments is to make code more testable and to improve code design. Does it make sense? How about initializing DAO object?...

how to simulate sequence during DAO layer test

junit,tdd,dao,spring-test
I have spring+hibernate project, I want to write Unit test case for DAO layers, Currently I am using HSqldb's in memory DB to test it. (I referred this ) In project, IDs are provided by sequences, As I am using in-memory DB, during test sequence are not presents so it...

Dealing with PostgreSQL %ROWTYPE returns

java,postgresql,jdbc,dao,plpgsql
I've got a PostgreSQL function which looks like this: CREATE FUNCTION myFunc() returns myTable as $$ DECLARE my_row myTable%ROWTYPE; BEGIN select * into strict my_row where...... return my_row EXCEPTION WHEN NO_DATA_FOUND THEN RAISE EXCEPTION 'Blame the user !' USING HINT = 'Its always the users fault !'; END; $$ LANGUAGE...

Converting ADODB Loop into DAO

excel,vba,ms-access,ado,dao
Hi I've been developing a vba project with a lot of help from examples here. I'm trying to access a MS Access database from Excel VBA and import large data sets (500-100+ rows) per request. Currently, the following loop works using ADODB however, the Range("").Copyfromrecordset line is taking very long...

Having issues migrating data with attachments in Access

ms-access,access-vba,sharepoint-2007,dao,attachment-field
All, I have an MS Access database that has some file attachments that I need to programmatically copy to another MS Access table (both tables are linked tables to a SharePoint 2007 list). I have the following code. Private Sub AddAttachments(rsSource As Recordset, rsDest As Recordset) Dim rs2Source As Recordset2...

Java DAO on server [closed]

java,client-server,dao
Locally I attach to my DAO from my client like so; try { AssetsDao _dao = getAssetsDao(); Assets _result[] = _dao.findAll(); for (int i=0; i<_result.length; i++ ) { display( _result[i] ); } } catch (Exception _e) { _e.printStackTrace(); } If my DAO tier is on another server, what are the...

How to test DAO methods using Mockito?

java,unit-testing,junit,mockito,dao
I've started to discovered Mockito library and there is a question for which I didn't find the proper answer. If I have for example such method in my UserDAO class that saves user in database: public class UserDAO{ ... public void create(User user) { Connection connection = null; PreparedStatement pstmt...

Hibernate : session.get(…) vs session.getNamedQuery(…)

java,hibernate,dao,hibernate-session
In the a transaction process I create/save an object and next to end of transaction I read again object (before setting an history event) @org.springframework.stereotype.Service @Transactional(value="transactionManager") public class UTServiceImpl implements UTService { private static final Logger logger = Logger.getLogger(UTServiceImpl.class); ... @Autowired private DeclarationDao declarationDao; ... public Integer ajouterPersonneImpliquee(ContexteService contexte, Integer...

Error “Object required” when running working parameterised Access SQL query (INSERT INTO) from Excel VBA

sql,vba,excel-vba,ms-access,dao
I'm running some VBA from an Excel file to update an Access database following data manipulation in Excel. It creates and executes the SQL lines via DAO links. On occasion the data to be entered contains characters which ruin SQL (e.g. an apostrophe in the values of an INSERT INTO...

DDD Repository: Use DAO for separation?

domain-driven-design,repository-pattern,dao
There is a controversial discussion of Repositories, their use and layout on stackoverflow and throughout the web. I am confused about how to implement the data access abstraction (e.g. database) behind a Repository efficiently. I am not using an ORM tool/framework as I want to see the gritty details myself....

Syntax for DAO 'Like' Select Query

sql,vba,like,dao
I'm sorry for bothering you all for what is probably a really simple problem. I use DAO Select queries fairly frequently but have never needed to filter using 'Like' based on a form field. The attached code, which should filter based on a combobox (comboRes), throws up a Syntax error...

What's the difference beetwen EntityManager and DAO? [closed]

java,java-ee,dao,entitymanager
What's the difference beetwen EntityManager and DAO? Is it same thing?

Close connection in DAO object [duplicate]

java,database,servlets,jdbc,dao
This question already has an answer here: Is it safe to use a static java.sql.Connection instance in a multithreaded system? 2 answers My DAO object package com.myselect; import java.sql.*; import java.sql.DriverManager; import java.util.logging.Level; import java.util.logging.Logger; public class DataAccess { Connection conn; PreparedStatement pst; ResultSet rs; public DataAccess() { try...

MongoDB Auto-Incrementing id field with java mongo driver?

java,dao,mongodb-java,morphia
Whole day I have tried to find a answer on the question: "How to add auto-Incrementing "id" field in an Entity class?". I am using Morphia (a type-safe java library for Mongo DB). After a couple hours of digging in source code and googling I have found a LongIdEntity class...

Several sql requests to retrieve data(hibernate)

java,mysql,hibernate,servlets,dao
Sorry for my English. Began to deal with javaee and do not quite understand how to make some operations. I have 2 tables categories and posts .In posts has fields id, namecat and index. In posts has fields id, namePost, text, idCat. If the table category index = 1. So...

How to test DAO with DataSource in Java Web Application?

java,unit-testing,datasource,jndi,dao
I'm doing my project using Tomcat 7, JSP, Servlets, Log4j and MySQL. I've googled this question for hours with no proper answer. How can I test my DAO's using DataSource and JUnit ? I found this article recently, but don't know how to configure it for my purposes and don't...

Spring Test DBUnit: Unable to load dataset from file

spring,testng,dao,dbunit,spring-test-dbunit
I'm trying to use Spring Test DBUnit for running an integration test that checks if a DAO's services are running correctly. For two similar entities, I was able to create tests that run OK, but for this particular entity, the test can't run properly. The test will be ignored, and...

Casting a list of objects to another one

c#,linq,casting,lambda,dao
I have the following classes(entities): Entity(base class, has 3 props) & Category(derives from Entity and adds some other props) The problem occurs when I read data from the DB(the fill method returns a list of Entities) and the compiler doesn't allow me to cast from Entity to Category. The problematic...