Bug 831130 - Can't create right datasource for scalable application
Summary: Can't create right datasource for scalable application
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: OKD
Classification: Red Hat
Component: Containers
Version: 2.x
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: ---
: ---
Assignee: Bill DeCoste
QA Contact: libra bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-06-12 09:32 UTC by Rony Gong 🔥
Modified: 2015-05-14 22:55 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-06-25 18:27:13 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Rony Gong 🔥 2012-06-12 09:32:36 UTC
Description of problem:
can't create right datasource for scalable applcition
after I look into the datasouce code in .openshift/confi/standalone.xml, I find:

                <datasource jndi-name="java:jboss/datasources/MysqlDS" enabled="${mysql.enabled}" use-java-context="true" pool-name="MysqlDS">
                    <connection-url>jdbc:mysql://${env.OPENSHIFT_DB_HOST}:${env.OPENSHIFT_DB_PORT}/${env.OPENSHIFT_GEAR_NAME}</connection-url>
                    <driver>mysql</driver>
                    <security>
                      <user-name>${env.OPENSHIFT_DB_USERNAME}</user-name>
                      <password>${env.OPENSHIFT_DB_PASSWORD}</password>
                    </security>
                </datasource>
                <datasource jndi-name="java:jboss/datasources/PostgreSQLDS" enabled="${postgresql.enabled}" use-java-context="true" pool-name="PostgreSQLDS" use-ccm="true">
                    <connection-url>jdbc:postgresql://${env.OPENSHIFT_DB_HOST}:${env.OPENSHIFT_DB_PORT}/${env.OPENSHIFT_GEAR_NAME}</connection-url>
                    <driver>postgresql</driver>
                    <security>
                      <user-name>${env.OPENSHIFT_DB_USERNAME}</user-name>
                      <password>${env.OPENSHIFT_DB_PASSWORD}</password>
                    </security>
                </datasource>


all that ${env.OPENSHIFT_GEAR_NAME} should be replaced by ${env.OPENSHIFT_APP_NAME}
or we can't get right datasource connection, except for nonscalable app.


Version-Release number of selected component (if applicable):
devenv_1807


How reproducible:
always


Steps to Reproduce:
1.create a scalable jboss app,embed my sql
2.then the mysql.jsp file to do a database connection:
<%@ page contentType="text/html" language="java" import="java.sql.*" %>
<%@ page import="javax.naming.*" %>
<%@ page import="javax.sql.*" %>
<%
InitialContext ctx = new InitialContext();
DataSource ds = (DataSource) ctx.lookup("java:jboss/datasources/MysqlDS");
Connection connection=ds.getConnection();
Statement statement = connection.createStatement();
statement.executeUpdate("DROP TABLE IF EXISTS ucctalk");
statement.executeUpdate("CREATE TABLE ucctalk (speaker CHAR(30), title CHAR(60))");
statement.executeUpdate("INSERT INTO ucctalk (speaker,title) VALUES ('Jeremy Zawodny', 'Optimizing MySQL'), ('Sanja Byelkin', 'Sub-Queries in MySQL'), ('Tim Bunce', 'Advanced Perl DBI')");
ResultSet rs = statement.executeQuery("SELECT * FROM ucctalk");
ResultSetMetaData rmeta = rs.getMetaData();
int numColumns=rmeta.getColumnCount();
while(rs.next()) {
    out.print(rs.getString(1));
    out.print(", ");
    out.print(rs.getString(2));
    out.print("<br>");
}
rs.close();
statement.close();
connection.close();
%>

3.git push, the access the mysql.jsp
  
Actual results:
show exception couldn't connect to database "9d3c69bffb"

Expected results:
create datasource success and could connect it.




Additional info:

Comment 1 Rony Gong 🔥 2012-06-13 01:25:09 UTC
sorry,
Version-Release number of selected component (if applicable):
devenv_1827

Comment 2 Rony Gong 🔥 2012-06-13 07:46:51 UTC
Retest on devenv1838, didn't found any change for that part.

Comment 3 Bill DeCoste 2012-06-13 20:08:55 UTC
OPENSHIFT_GEAR_NAME was replaced with OPENSHIFT_APP_NAME in the datasource configurations - confirmed in ami 58d77431. Is there another issue?

Comment 4 Rony Gong 🔥 2012-06-14 05:28:23 UTC
verified on devenv_1843

all ${env.OPENSHIFT_GEAR_NAME} changed to ${env.OPENSHIFT_APP_NAME}
and could connect datasource success.


Note You need to log in before you can comment on or make changes to this bug.