Return-Path: X-Original-To: apmail-commons-user-archive@www.apache.org Delivered-To: apmail-commons-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B288FFB28 for ; Thu, 28 Mar 2013 03:49:58 +0000 (UTC) Received: (qmail 49942 invoked by uid 500); 28 Mar 2013 03:49:57 -0000 Delivered-To: apmail-commons-user-archive@commons.apache.org Received: (qmail 49540 invoked by uid 500); 28 Mar 2013 03:49:53 -0000 Mailing-List: contact user-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Users List" Delivered-To: mailing list user@commons.apache.org Received: (qmail 49513 invoked by uid 99); 28 Mar 2013 03:49:52 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 28 Mar 2013 03:49:52 +0000 X-ASF-Spam-Status: No, hits=2.2 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [209.85.220.182] (HELO mail-vc0-f182.google.com) (209.85.220.182) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 28 Mar 2013 03:49:44 +0000 Received: by mail-vc0-f182.google.com with SMTP id ht11so7264863vcb.27 for ; Wed, 27 Mar 2013 20:49:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-received:x-originating-ip:date:message-id:subject :from:to:content-type:x-gm-message-state; bh=dkxoAxvsouZwlK2f63LcUkOT//SRGYQ1m+73g8wZqwg=; b=LgLdJdNdy3FvdA74QEzcu2UpEw0FNnWsabGiLlqL+A5086cJwVKE0yLBdMQucipObT d5NPqO3tlXhsLayeYhvMhK5ALeo06oyAwmmUP0I9d+Y8Y/dOYRS9tkl7SciTPF4hJyhB GN8Ci7TAnjlR+8p0TXXSlLpCXRlbxEmR/vSw1QrXdqr8TeWFJcPcC9usQFBOw+LHK2hV bqcXXL/6vhiYXA95dfCQc3K8twZrTqDfhKDKPH+hT/TdEyVN2y8xsrY47PGXIlC8SRD0 b3SnL72nG06DUeqFmcr8OdceTDy7ZIhumtJ6GCet7Ax87kMeBOkzf5RP3uFmzyaN+VNI rOhg== MIME-Version: 1.0 X-Received: by 10.58.80.4 with SMTP id n4mr25605819vex.5.1364442563373; Wed, 27 Mar 2013 20:49:23 -0700 (PDT) Received: by 10.220.124.142 with HTTP; Wed, 27 Mar 2013 20:49:23 -0700 (PDT) X-Originating-IP: [183.88.112.8] Date: Thu, 28 Mar 2013 10:49:23 +0700 Message-ID: Subject: DBCP PoolingDataSource.GetConnection returns error From: Nayana Hettiarachchi To: user@commons.apache.org Content-Type: multipart/alternative; boundary=047d7b5d62644eac2404d8f40a14 X-Gm-Message-State: ALoCoQlW400f8H1eiNrSexNo89TwGyMwtpCL/aEA6Oaze6h5UqrDYDzHdG1aeK7qYatVJuNK2GH7 X-Virus-Checked: Checked by ClamAV on apache.org --047d7b5d62644eac2404d8f40a14 Content-Type: text/plain; charset=ISO-8859-1 Hi There, I have the following code, where i initialize the dbcp at the end when i call datasource.GetConnection() i get an MySQLSyntaxErrorException saying Access denied for user ''@'localhost' to database 'sna_web' Looking at the error it seems like the pool have lost the auth information to connect to the datasource like the Username and Password, because the username is not mentioned in the error. Has anyone had this problem before or have seen it? any help is greatly appreciated. Nayana MySqlProp mysqlprop; mysqlprop = new MySqlProp(PropBase.class.getResourceAsStream("mysql.properties")); Properties props = new Properties(); props.setProperty("Username", mysqlprop.getProperty(MySqlProp.USERNAME)); props.setProperty("Password", mysqlprop.getProperty(MySqlProp.PASSWORD)); ConnectionFactory connectionFactory = new DriverConnectionFactory(new com.mysql.jdbc.Driver(), mysqlprop.getProperty(MySqlProp.CONSTRING), props); KeyedPoolableObjectFactory kpf = new BaseKeyPoolObjectFactory(); ObjectPool op = new GenericObjectPool(); KeyedObjectPoolFactory pbpf = new GenericKeyedObjectPoolFactory(kpf); Collection initsql = new ArrayList(); poolableConnectionFactory = new PoolableConnectionFactory(connectionFactory, op, pbpf, "SELECT VERSION()", initsql, true, true); connectionPool = new GenericObjectPool(poolableConnectionFactory); dataSource = new PoolingDataSource(connectionPool); --047d7b5d62644eac2404d8f40a14--