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

Recommended Answers

All 2 Replies

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 */ }
               }
           }
       }
   }

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.