Thread: hello guys can anyone let me know how to?

Results 1 to 4 of 4
  1. #1 hello guys can anyone let me know how to? 
    RSPS SERVICES PROVIDER

    The Plateau's Avatar
    Join Date
    May 2015
    Posts
    999
    Thanks given
    592
    Thanks received
    191
    Rep Power
    129
    well i have now Zarketh and i have mysql datebase and have myadminphp but i don't know how to set it up can anyone

    let me know how to set it up ? pls
    Reply With Quote  
     

  2. #2  
    Community Veteran


    Arch337's Avatar
    Join Date
    Sep 2008
    Posts
    2,950
    Thanks given
    210
    Thanks received
    349
    Rep Power
    1376
    A Mysqlconnector jar file and a class to load it, is all you need at the start. Then the rest is depended on what you wish to do with it.


    "A fail act is something you do regular, but a dumb act is something you can learn from"
    Spoiler for Problem?:
    Reply With Quote  
     

  3. #3  
    RSPS SERVICES PROVIDER

    The Plateau's Avatar
    Join Date
    May 2015
    Posts
    999
    Thanks given
    592
    Thanks received
    191
    Rep Power
    129
    Quote Originally Posted by arch337 View Post
    A Mysqlconnector jar file and a class to load it, is all you need at the start. Then the rest is depended on what you wish to do with it.
    رThanks to respond can you presented me good server to host him ?
    Reply With Quote  
     

  4. #4  
    Community Veteran


    Arch337's Avatar
    Join Date
    Sep 2008
    Posts
    2,950
    Thanks given
    210
    Thanks received
    349
    Rep Power
    1376
    Quote Originally Posted by dr man 12 View Post
    رThanks to respond can you presented me good server to host him ?
    Here's the class:
    Spoiler for open me:

    Code:
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    
    public class MySql {
    
    
        private Connection conn = null;
        public Statement stm = null;
        public PreparedStatement pst = null;
        public ResultSet rs = null;
    
        public String Adress = "";
        public String DataBase = "";
        public String Username = "";
        public String Password = "";
        public int port = 3306;
    
    
        public Connection mysql_connect() {
            try {
                Class.forName("com.mysql.jdbc.Driver").newInstance();
                Connection con = DriverManager.getConnection(
                        "jdbc:mysql://"+Adress+":"+port+"/"+DataBase, ""+Username,
                        ""+Password);
                return con;
            } catch (Exception e) {
                System.out.println("No MySql response!");
                e.printStackTrace();
                return null;
            }
        }
    
        public Connection getConnection() {
            try {
                if (conn.isClosed()) {
                    conn = DriverManager.getConnection(
                            "jdbc:mysql://"+Adress+":"+port+"/"+DataBase, ""+Username,
                            ""+Password);
                }
            } catch (SQLException e) {
                e.printStackTrace();
            }
            return conn;
        }
        public int tries = 0;
        public void loadMySQL() {
            System.out.println("Starting MySQL connection");
            try {
                if (conn == null || conn.isClosed()) {
                    conn = mysql_connect();
                    if (conn == null) {
                        System.out.println("Error connecting to mysql");
                        tries++;
                        if (tries > 5) {
                            //System.exit(1);
                            System.out.println("Too many mysql tries!");
                        } else {
                            loadMySQL();
                        }
                    }
                    System.out.println("Connected to MySQL!");
                }
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    
        public static void pingServer() {
            //System.out.println("Pinging server");
            try {
                PreparedStatement ps = Server.mysql.getConnection().prepareStatement("select 1");
                if (!ps.execute()) {
                    System.out.println("Error");
                } else {
                    System.out.println("Pinging server");
                }
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    
    }
    Your main class:
    Code:
    public static MySql mysql = new MySql();
    mysql.loadMySQL(); //under your main(String[] args)


    Here's for the jar:
    MySQL :: Download Connector/J


    "A fail act is something you do regular, but a dumb act is something you can learn from"
    Spoiler for Problem?:
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Replies: 1
    Last Post: 04-27-2015, 04:23 PM
  2. Replies: 2
    Last Post: 09-17-2013, 07:20 AM
  3. Replies: 4
    Last Post: 09-01-2010, 01:47 PM
  4. Can anyone give me the link to this soruce?
    By every1thing in forum Help
    Replies: 4
    Last Post: 08-28-2010, 02:55 AM
  5. Replies: 0
    Last Post: 06-09-2009, 08:30 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •