Home Answers Viewqa JDBC Connecting to remote mysql server using jdbc.

 
 


Java Coder
Connecting to remote mysql server using jdbc.
1 Answer(s)      a year and a month ago
Posted in : JDBC

How to Connect to remote mysql server using jdbc.

View Answers

May 11, 2012 at 11:08 AM


First configure your MySQL server to accept remote connections by enabling external connection for MySQL server. Use the IP / hostname of the remote machine in your database connection string, instead of localhost.

Example :

package roseindia.net;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class RemoteMYSQLServer {
        public static void main(String[] args) throws SQLException {
                Connection con = null
                Statement stmt = null; 
                ResultSet rs = null;

                String conUrl = "jdbc:mysql:// 192.168.10.25:3306/";
                String driverName = "com.mysql.jdbc.Driver";
                String databaseName = "student";
                String usrName = "root";
                String usrPass = "root";
                try {
                        // Loading Driver
                        Class.forName(driverName). newInstance();
                } catch (ClassNotFoundException e) {
                        System.out.println(e.toString());
                }
                try {
                        // Getting Connection
                        con = DriverManager.getConnection(conUrl + databaseName, usrName,
                                        usrPass);
                        stmt = con.createStatement();

                        String query = "SELECT * FROM  student'";

                       rs= stmt.executeUpdate(query);
                   if (rs.next()) {
                System.out.println(rs.getString(1));
            }

                } catch (Exception e) {
                        System.out.println(e.toString());
                } finally {
                        // Closing Connection
                        con.close();
                        stmt.close();
                }
        }
}









Related Pages:
Connecting to remote mysql server using jdbc.
Connecting to remote mysql server using jdbc.  How to Connect to remote mysql server using jdbc
Connecting to the Database Using JDBC and Pure Java driver
Connecting to the Database JDBC Driver In our search engine we are using MySQL database server and MM.MySQL Driver... this driver to make connections to MySQL server from both Java
Connecting to MySQL
(); bds.setDriverClassName("com.mysql.jdbc.Driver"); bds.setUrl("jdbc:mysql...-dbcp.jar, commons-pool.jar, j2ee.jar and mysql-connector-java-5.1.7-bin.jar...-collections.jar;lib/commons-dbcp.jar;lib/commons-pool.jar;lib/j2ee.jar;lib/mysql
Connecting to MYSQL Database in Java
Connecting to MYSQL Database in Java  I've tried executing the code... = "jdbc:mysql://localhost/"; String dbName = "textbook"; String driver... the following link: JDBC MySQl Connectivity   I have mysql-connector
Encountering error when connecting MSSQL Server 2005 using Hibernate 3.0
Encountering error when connecting MSSQL Server 2005 using Hibernate 3.0 ... the following error when connecting to the MSSQLServer 2005 using hibernate 3.0 My hibernate.cfg.xml is as under net.sourceforge.jtds.jdbc.Driver jdbc
connecting databases
connecting databases  I need to connect mysql on 2 or more remote pc'c. how can i giv the ip address for 2 or more systems. is it possible to connect to the required systems by user specifying the database and table name my
can't connect to MySQL Server(10060) - JDBC
created a DB in the Hosting MySQL server and now i want to create a table By using MySQL front end. Can we connect to the MySQL server using the I.P address...can't connect to MySQL Server(10060)  Hii Sir, I am working
using pb datawindow activex with jdbc for mysql - JDBC
using pb datawindow activex with jdbc for mysql  Hi, I am trying to use datawindow activex in a web page. I need to connect to mysql database located on the server. I have downloaded the connectj for mysql. What should
doubt in connecting to mysql in flex - XML
doubt in connecting to mysql in flex  The ?Create application from... clicks;Here is an example whichusephp as back-end and MySql as DataSource:First... = innodb; Than create a project that use PHP as server technology:Right Click
doubt in connecting mysql in flex - XML
doubt in connecting mysql in flex  The ?Create application from... clicks;Here is an example whichusephp as back-end and MySql as DataSource:First...; Than create a project that use PHP as server technology:Right Click
java connecting to oracle db - JDBC
java connecting to oracle db  how to connect oracle data base... oracle.jdbc.driver.*; import oracle.sql.*; 2) Load and Register the JDBC driver...) Connect to database:*********** a) If you are using oracle oci driver,you have
Connecting to a database through the Proxy.
Connecting to a database through the Proxy.  Connecting to a database through the Proxy I want to connect to remote database using a program that is running in the local network behind the proxy. Is that possible
Error in connecting to the mySQL database in TOMCAT using more than one PC (database connection pooling)
Error in connecting to the mySQL database in TOMCAT using more than one PC...="com.mysql.jdbc.Driver" url="jdbc:mysql://10.9.58.8:3306/alcs_htht"/> </Context>...-INF/web.xml</WatchedResource> <Resource name="jdbc/HTHLogDB" auth
Connecting to MySQL database and retrieving and displaying data in JSP page
Connecting to MySQL database and retrieving and displaying data in JSP page... web application. Creating Table in the database. Using a JDBC driver...; Statement stmt=null; try{ String url="jdbc:mysql
Tomcat Server configuration with Eclipse at remote machine
Tomcat Server configuration with Eclipse at remote machine  "Several... may be using the port. To start this server you will need to stop the other... same web application on remote machine by different users using different
mysql installation problem - JDBC
mysql installation problem  Hi, when i installing mysql server on my pc in MySQL Server Instance Configuration Wizard,I enter the root pw.... Access denied for user 'root'@'localhost' (using password:NO) Please tell me
could not connect to the server - JDBC
to the remote MySqL server, i got an exception like...) at java.lang.Thread.run(Unknown Source) ** END NESTED EXCEPTION ** Last packet sent to the server...;Hi friend, Read for more information. http://www.roseindia.net/jdbc
How to send URL in Post request from local server to remote server?
How to send URL in Post request from local server to remote server?  ... server(using Tomcat). Now i want: 1> How to establish a Connection... containing- "https://IPAddress:Port/contextpath/parameters" to remote server
Connecting to a MySQL Database in Java
Connecting to a MySQL Database in Java   ... for a manipulation. We have many database provided like Oracle, MySQL etc. We are using MySQL... data form MySQL database. We are going to make a program on connecting to a MySQL
run exe on remote client
run exe on remote client  I am making a client server application using netbins 6.1 , Jsp servlet, Mysql5.1... I want to run an batch file or exe... copied files fromserver to client using my application but i cant run it on remote
not able to connect to mysql using.. jdbc
not able to connect to mysql using.. jdbc   i am not able to connect to mysql using jdbc .. is there any classpath that i need to set..because i am using mysql-connector-java jar file..to connect to mysql.. Pls provide the steps
Null pointer exceptation-Java Servlet web application,Problem connecting with MYSQL database
="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/database_name?autoReconnect...="password" driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost...Null pointer exceptation-Java Servlet web application,Problem connecting
remote procedure call using java - JSP-Servlet
remote procedure call using java  what is the romote procedure call and related coding in java?  Hi Friend, The RPC (Remote Procedure... to be communicated to a remote server. JAX-RPC makes it easier for applications or Web
jdbc mysql - JDBC
=DriverManager.getConnection("jdbc:mysql://localhost:3306/ram","root","root...jdbc mysql  import java.sql.*; public class AllTableName... sent to the server was 31 ms ago. at com.mysql.jdbc.Connection.createNewIO
connecting servlet to db2 - JSP-Servlet
connecting servlet to db2  Hello sir, Iam new to db2.so I would like... the configuration we need to be done before connecting to the db2(such as what path we have to set and all).  If u are using the oracle Database 9i
Remote Desktop Services
Remote Desktop Services Formerly known as Terminal Services in Windows Server 2008, the Remote Desktop Services in Windows Server 2008 R2 is Microsoft...). Moreover, Remote Desktop Services (RDS) is a property of Windows Server 2008 R2
ssh to remote server - JavaMail
ssh to remote server  I designed an application for feedback, in that application i want to write a code for automatic mail sending, can you please tell me how to write code for that. Please help us
MySQL Client
applications to make SQL queries to a remote MySQL Server across a TCP/IP connection... provides a graphical interface to the MySQL server. It can be thought... connecting to the server with a pre-4.1 client program, use an account that still has
MySQL Client
applications to make SQL queries to a remote MySQL Server across a TCP/IP connection...). This general-purpose client provides a graphical interface to the MySQL server. It can... library.  * When connecting to the server with a pre-4.1 client
Remote desktop access - JSP-Servlet
Remote desktop access  Hello everyone Thank a lot for all the reply given before i have my 4th question which is about Remote desktop... reply me Thank a lots in advance   I forgot to say i am using jsp
Connecting JTable to database - JDBC
Connecting JTable to database  Hi.. I am doing a project on Project Management System for which i created the user interfaces.. I have a user...("jdbc:odbc:access"); for(int i=0;i  Hi Friend, Make one change
java jdbc connecting probelm - JDBC
java jdbc connecting probelm  import javax.servlet.*; import javax.servlet.http.*; import javax.sql.*; import java.io.*; public class ECom...=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","scott","tiger
database connectivity using mysql
seconds) I am using Netbeans 5.5, mysql server 5.0, to get data from table...[]) throws SQLException { try { String connectionURL = "jdbc:mysql...database connectivity using mysql  java file: eg1.java package eg
mysql jdbc connectivity
mysql jdbc connectivity  i want to connect retrieve data from mysql using jdbc
JDBC Training, Learn JDBC yourself
JDBC Connection Pooling Accessing Database using Java and JDBC Learn how to access database using JDBC.   Enhanced SQL Exception Handling... with MySQL JDBC MySQL Tutorial JDBC Tutorials with MySQL Database
jsp using include & with mysql
jsp using include & with mysql  Sir, I am creating a login application using jsp & Mysql. The Codes are--- Html File...... <...; <param-value>jdbc:mysql://localhost:3306/userinfo</param-value> <
mysql
mysql  How can install My sql drivers using a jar File   Hi you need to download the mysql-connector jar file for connecting java program from mysql database.......   Hi friend, MySQL is open source database
Prepared statement JDBC MYSQL
Prepared statement JDBC MYSQL  How to create a prepared statement in JDBC using MYSQL? Actually, I am looking for an example of prepared statement.   Selecting records using prepared statement in JDBC
connecting jsp to mysql - JSP-Servlet
connecting jsp to mysql  Hi, i am working on 'Web application development' project that uses JSP, MySQL and tomcat.i am not able to connect to the mysql database through jsp. After downloading the mysql-connector-java-5.0  
how to connect mysql with JDBC - JDBC
in the database MYsql, i have to connect them now using JDBC, can u please suggest me...(); } } Thanks Rajanikant  Hi friend, To mysql connect using JDBC... { connection = DriverManager.getConnection("jdbc:mysql://localhost
Connecting to Database from a hyperlink in JSP - JSP-Servlet
which is connect to database using jdbc database...Connecting to Database from a hyperlink in JSP  How can I connect...://www.roseindia,net/jsp/ http://www.roweindia.net/jdbc/ Thanks.   http
spring mvc configuration with mysql using jdbc
spring mvc configuration with mysql using jdbc  hai I want to configure web mvc with mysql using jdbc template. when I submit values using registration form it will reflect on database which i was created earlier. send me code
Mysql & java - JDBC
to connect to mysql 5.1 using java. But it shows error about: Class.forName...; String url = "jdbc:mysql://localhost:3306/"; String dbName... on JDBC visit to : http://www.roseindia.net/jdbc/jdbc-mysql/MysqlConnect.shtml
jdbc driver for mysql - Java Beginners
jdbc driver for mysql  I need jdbc driver program for connecting java progrma to mysql. Please any one send me the url to download the driver... of jdbc-mysql database connectivity and idea about jdbc and mysql driver
No suitable driver found for jdbc:mysql://localhost:3306/TEST
No suitable driver found for jdbc:mysql://localhost:3306/TEST  hii, I have wrietten web project using jsp and hibernate but its not working. ava.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/TEST
Server DB connection - JDBC
Server DB connection  Hello Guys I want to connect two databases.... One database is on my localhost and the other one is on server, I want to transfer the data from my localhost database to the database on the server. I have
java - JDBC
have to use JDBC and oracle. plz send the details for connecting "java... sending data inserting code into database using JDBC with jsp... for database connectivity: http://www.roseindia.net/jdbc/jdbc-mysql
MySQL Front
-developers using the popular MySQL-Database. It allows you to manage and browse... In this article, we will take a look at the basics of connecting to and using...; In this article, we will take a look at the basics of connecting to and using one
regarding jdbc - JDBC
").newInstance(); con = DriverManager.getConnection("jdbc:mysql:///test...("Successfully connected to MySQL server..."); } catch(Exception e... on JDBC visit to : http://www.roseindia.net/jdbc/jdbc-mysql/MysqlConnect.shtml