How do I connect a Java application to the Mysql-in App on Azure?

Asked

Viewed 135 times

-2

How to connect an application via url to the Mysql database (Myslq-inApp) within Azure ?

        String urlLOCAL = "jdbc:mysql://localhost:3306/crudjsp";
        String urlAzure = "jdbc:";


        Class.forName("com.mysql.jdbc.Driver"); 

        Connection conn = DriverManager.getConnection(urlLOCAL,"root","");
        Statement stmt = conn.createStatement();

        ResultSet rs = stmt.executeQuery("SELECT * FROM usuarios");

inserir a descrição da imagem aqui

1 answer

0


The connection in the Mysql-Inapp database in Azure is very similar to the local connection of the Xampp server. Simply set the user variables: "Azure", password:"passwordDositema" and host:"local" to make the connection. My code looks like this:

String user = "azure";
String password = "6#vWHD_$";

String urlAzure= "jdbc:mysql://127.0.0.1:54447/localdb";    
Class.forName("com.mysql.jdbc.Driver"); 

Connection conn = DriverManager.getConnection(urlAzure,user,password);      
Statement stmt = conn.createStatement();

ResultSet rs = stmt.executeQuery("SELECT * FROM usuarios");

Answer obtained from this post: https://stackoverflow.com/questions/41601885/azure-where-is-default-user-pass-for-wordpress-database-using-mysql-in-appprev

Browser other questions tagged

You are not signed in. Login or sign up in order to post.