简体   繁体   中英

how can i connect android application to mysql using jsp?

I want to use jsp rather than php. Is it by jdbc driver? And what are the steps.

            Class.forName("com.mysql.jdbc.Driver");
            Connection con = DriverManager.getConnection(
                    "jdbc:mysql://<server>/<database>",
                    <username>,
                    <password>);

            Statement stmt = con.createStatement();
            ResultSet rs = stmt.executeQuery("SELECT access_name, access_code FROM user_login");

            while (rs.next()) {
                x = rs.getString("access_name");
                y = rs.getString("access_code");
            }

This code gives me an exception like ClassNotFoundException com.mysql.jdbc.driver

You should download MySQL Connector from this link :
https://dev.mysql.com/downloads/connector/j/5.0.html .
Then just add it to your classpath.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM