0

hai
i am write simple java code dataRetriving from Mysqldatabase to c:\ Commend fromt The out put desplay QUERY send me Plse

3
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by jwenting
0

MySQL Connector/J is the interface between the two. Are you using java or javascript? If you are using script then you can use php with a hidden iframe and post your variables to and from the iframe. Using java with the Connector/J would be like the following:

   import java.sql.*;

   public class Connect
   {
       public static void main (String[] args)
       {
           Connection conn = null;

           try
           {
               String userName = "demouser";
               String password = "demopassword";
               String url = "jdbc:mysql://localhost/demo";
               Class.forName ("com.mysql.jdbc.Driver").newInstance ();
               conn = DriverManager.getConnection (url, userName, password);
               System.out.println ("Database connection established");
           }
           catch (Exception e)
           {
               System.err.println ("Cannot connect to database server");
           }
           finally
           {
               if (conn != null)
               {
                   try
                   {
                       conn.close ();
                       System.out.println ("Database connection terminated");
                   }
                   catch (Exception e) { /* ignore close errors */ }
               }
           }
       }
   }

Edited by Dani: Formatting fixed

0

Both of you should read the announcement of the rules. NO HOMEWORK HELP to be either given or requested.
We're NOT here to do your homework for you, and that includes both of you.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.