Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Use <b>appfog</b> environment variable called VCAP_SERVICES to automatically detect your MySQL database credentials and connection info. You can take advantage of this to display all the info which will be in JSON format and use it to connect your app to MySQL database. You may try this.</p> <ul> <li><p>First create a servlet and retrieve your database connection using a context attribute as follows:</p> <pre><code>public class DbInfoServlet extends HttpServlet { public void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException { request.setAttribute("jsonContent", java.lang.System.getenv("VCAP_SERVICES")); request.getRequestDispatcher("/index.jsp").view.forward(request, response); } } </code></pre></li> <li><p>Then create a index.jsp file to display you DB connection info as follows:</p> <pre><code>&lt;body&gt; &lt;p&gt; &lt;!-- Click here to display DB info --&gt; &lt;a href="/DbInfoServlet"&gt;&lt;/a&gt; &lt;!-- Display of your DB connection and credentials info is here. This will show in JSON document format --&gt; &lt;c:out value="${jsonContent}" /&gt; &lt;/p&gt; &lt;/body&gt; </code></pre></li> <li><p>Use hostname(i.e. IP), port, name(i.e. database name), username, password parameters from JSON document content to modify your JDBC connection code as follows:</p> <pre><code>try { String connectionURL = "jdbc:mysql://hostname:3306/name"; Class.forName("com.mysql.jdbc.Driver"); conn = DriverManager.getConnection(connectionURL, username, password); statement = conn.createStatement(); } </code></pre></li> <li><p>If the above doesn't work, simply ensure that you are using the latest version of MySQL-connector-java jar file.</p></li> </ul> <p>Have fun!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload