I want to access an other database (not jira dabase) and i config datasource in entityengine.xml
<delegator name="default2" entity-model-reader="main" entity-group-reader="main"> <group-map group-name="default2" datasource-name="defaultDS2"/> </delegator> <!-- 10.10.192.83/glpi reader read@pgs$2012--> <datasource name="defaultDS2" helper-class="org.ofbiz.entity.datasource.GenericHelperDAO" field-type-name="mysql" check-on-start="true" add-missing-on-start="true" check-pks-on-start="false" use-foreign-keys="true" join-style="ansi-no-parenthesis" alias-view-columns="false" drop-fk-use-foreign-key-keyword="true" table-type="InnoDB" character-set="latin1" collate="latin1_swedish_ci"> <read-data reader-name="seed"/> <read-data reader-name="seed-initial"/> <read-data reader-name="demo"/> <read-data reader-name="ext"/> <inline-jdbc jdbc-driver="com.mysql.jdbc.Driver" jdbc-uri="jdbc:mysql://localhost/mydb?autoReconnect=true" jdbc-username="root" jdbc-password="" isolation-level="ReadCommitted" pool-minsize="2" pool-maxsize="20"/> <!--jndi-jdbc jndi-server-name="localjndi" jndi-name="java:/MySqlDataSource" isolation-level="Serializable"/--> </datasource>
and i access the database like this :
SQLProcessor sqlProcessor = null; ResultSet rs = null; List<GlpiGroup> list = new ArrayList<GlpiGroup>(); try { //构造sqlProcessor String sql = "select * from glpi_entities where entities_id = '"+pid+"'"; sqlProcessor = new AutoCommitSQLProcessor("defaultDS2"); sqlProcessor.prepareStatement(sql); rs = sqlProcessor.executeQuery(); while(rs.next()){ GlpiGroup gg = new GlpiGroup(); gg.setId(rs.getString("id")); gg.setName(rs.getString("name")); gg.setGroupsId(rs.getString("entities_id")); list.add(gg); } return list; } catch (GenericDataSourceException e) { e.printStackTrace(); } catch (GenericEntityException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); }finally{ try { sqlProcessor.close(); rs.close(); } catch (GenericDataSourceException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } } return list;
in jira5.0.2 it is OK but in jira5.1.6 have exception:
2012-11-18 23:45:40,453 http-8083-3 ERROR zhangzining 1402x82x1 yth9c5 127.0.0.1 /secure/QuickCreateIssue!default.jspa [NoModule] Error getting datasource via DBCP: JdbcDatasourceInfo{uri='jdbc:mysql://localhost/mydb?autoReconnect=true', driverClassName='com.mysql.jdbc.Driver', username='root', password='********', isolationLevel='ReadCommitted', connectionProperties=null, connectionPoolInfo=ConnectionPoolInfo{maxSize=20, minSize=2, initialSize=null, maxIdle=20, maxWait=60000, sleepTime=300000, lifeTime=600000, deadLockMaxWait=600000, deadLockRetryWait=10000, validationQuery=null, minEvictableTimeMillis=null, timeBetweenEvictionRunsMillis=null, poolPreparedStatements=null, testOnBorrow=null, testOnReturn=null, testWhileIdle=null, maxOpenPreparedStatements=null, numTestsPerEvictionRun=null, removeAbandonedTimeout=null, validationQueryTimeout=null, defaultCatalog=null}}
java.lang.RuntimeException: javax.management.InstanceAlreadyExistsException: com.atlassian.jira:name=BasicDataSource
。。。
。。。
Caused by: javax.management.InstanceAlreadyExistsException: com.atlassian.jira:name=BasicDataSource
。。。
。。。
why? who can help me! thanks a lot!
Community moderators have prevented the ability to post new answers.
are you sure that this is correct?
uri='jdbc:mysql://localhost/mydb?autoReconnect=true', driverClassName='com.mysql.jdbc.Driver', username='root', password='********',
i believe mydb needs the name of your database where your jira is connected to..
configuring an application to use root as DB login or running as root is not a good choice...
if you're 100 % sure that this are the right values then please try to login to the DB directly from your servers command line.
mysql -uroot -p mydb (ENTER will ask for your password)
just try connecting manually and let me know how it goes
I am sure it is correct, mysql is in my computer db name is "mydb" username and password is also correct
I use Navicat for MySQL can correct to the database,
and i can get the data from the database,only have errors in console.
have no error in version jira5.0.2 but have errors in jira5.1.6
i do not know why?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.