Java and Mysql

Java and Mysql

Sir,

I want to connect my java program with mysql server (mysql server is situated on another windows machine ) ??? ???? ?????

View Answers

May 16, 2012 at 1:57 PM

Put mysql jar file in your jdk lib and set the classpath. After that start the compiler and compile the given code.

import java.sql.*;

public class MysqlConnect{
  public static void main(String[] args) {
  System.out.println("MySQL Connect Example.");
  Connection conn = null;
  String url = "jdbc:mysql://localhost:3306/";
  String dbName = "jdbctutorial";
  String driver = "com.mysql.jdbc.Driver";
  String userName = "root"; 
  String password = "root";
  try {
  Class.forName(driver).newInstance();
  conn = DriverManager.getConnection(url+dbName,userName,password);
  System.out.println("Connected to the database");
  conn.close();
  System.out.println("Disconnected from database");
  } catch (Exception e) {
  e.printStackTrace();
  }
  }
}

For more information, visit the following link:

JDBC Tutorials


May 16, 2012 at 2:04 PM

sir mysql server is on another system.

Ads









Related Tutorials/Questions & Answers:
Java and MySQL
Java and MySQL   I am doing a project on an accounting system. I need to know to things: How do I write reports using information in an MySQL database . How get multiple MySQL database rows and assign them to variables r
Java and Mysql
Java and Mysql  Sir, I want to connect my java program with mysql server (mysql server is situated on another windows machine ) ??? ???? ?????   Put mysql jar file in your jdk lib and set the classpath. After
Advertisements
Version of mysql>mysql-connector-java dependency
List of Version of mysql>mysql-connector-java dependency
mysql-java
mysql-java   i try to execute this code stmt1.executeUpdate("insert... the manual that corresponds to your MySQL server version for the right syntax to use...) at Mydb.main(Mydb.java:111) Java Result: 1 please help me to find the error  
java & mysql
java & mysql  I wrote the code as shown below, i am getting the error... to your MySQL server version for the right syntax to use near '' at line 1" my...("com.mysql.jdbc.Driver"); Connection con=DriverManager.getConnection("jdbc:mysql
java & mysql
java & mysql  I wrote the code as shown below, i am getting the error... to your MySQL server version for the right syntax to use near '' at line 1" my...("com.mysql.jdbc.Driver"); Connection con=DriverManager.getConnection("jdbc:mysql
java & mysql
java & mysql  I wrote the code as shown below, i am getting the error... to your MySQL server version for the right syntax to use near '' at line 1" my...("com.mysql.jdbc.Driver"); Connection con=DriverManager.getConnection("jdbc:mysql
java & mysql
java & mysql  I wrote the code as shown below, i am getting the error... to your MySQL server version for the right syntax to use near '' at line 1" my...("com.mysql.jdbc.Driver"); Connection con=DriverManager.getConnection("jdbc:mysql
java & mysql
java & mysql  I wrote the code as shown below, i am getting the error... to your MySQL server version for the right syntax to use near '' at line 1" my...("com.mysql.jdbc.Driver"); Connection con=DriverManager.getConnection("jdbc:mysql
connection with MySQL to java.
connection with MySQL to java.   how to connect MySQL database with jsp
Java connectivity with MySQL
Java connectivity with MySQL  Java connectivity with MySQL
MySql,java
MySql,java  In MySQL table i am adding the fields of name,photo,video,age,category.in the category i have some subjects.if one person login into my-site the he upload the one video under one subject.then i want the following
MYSQL Java Connector Library
Where to download the MYSQL Java Connector Library and get the jar file This article discuss 'how to connect Java and MYSQL using MYSQL connector' in Java. The article will give you view on downloading and installing MYSQL Java
mysql
you need to download the mysql-connector jar file for connecting java program from mysql database.......   Hi friend, MySQL is open source database... is the link for the page from where you can understand how to Download and Install MySQL
how to migrate java db to mysql
how to migrate java db to mysql  I have an aplication,for migrating java db to mysql db.how it will done
Connecting to MYSQL Database in Java
Connecting to MYSQL Database in Java  I've tried executing the code...("MySQL Connect Example."); Connection conn = null; String url = "jdbc:mysql://localhost/"; String dbName = "textbook"; String driver
JBBC ,MYSQL ND JAVA
JBBC ,MYSQL ND JAVA  import java.sql.*; import...:mysql://localhost/ACCOUNT","root","ADMIN"); st=con.createStatement...("com.mysql.jdbc.Driver"); con=DriverManager.getConnection("jdbc:mysql://localhost:3306/test
Maven Dependency mysql-connector-java >> 2.0.14
You should include the dependency code given in this page to add Maven Dependency of mysql >> mysql-connector-java version2.0.14 in your project
Maven Dependency mysql-connector-java >> 3.0.10
You should include the dependency code given in this page to add Maven Dependency of mysql >> mysql-connector-java version3.0.10 in your project
Maven Dependency mysql-connector-java >> 3.0.8
You should include the dependency code given in this page to add Maven Dependency of mysql >> mysql-connector-java version3.0.8 in your project
Maven Dependency mysql-connector-java >> 3.1.11
You should include the dependency code given in this page to add Maven Dependency of mysql >> mysql-connector-java version3.1.11 in your project
Maven Dependency mysql-connector-java >> 3.1.12
You should include the dependency code given in this page to add Maven Dependency of mysql >> mysql-connector-java version3.1.12 in your project
Maven Dependency mysql-connector-java >> 3.1.13
You should include the dependency code given in this page to add Maven Dependency of mysql >> mysql-connector-java version3.1.13 in your project
Maven Dependency mysql-connector-java >> 3.1.14
You should include the dependency code given in this page to add Maven Dependency of mysql >> mysql-connector-java version3.1.14 in your project
Maven Dependency mysql-connector-java >> 5.0.2
You should include the dependency code given in this page to add Maven Dependency of mysql >> mysql-connector-java version5.0.2 in your project
Maven Dependency mysql-connector-java >> 5.0.3
You should include the dependency code given in this page to add Maven Dependency of mysql >> mysql-connector-java version5.0.3 in your project
Maven Dependency mysql-connector-java >> 5.0.4
You should include the dependency code given in this page to add Maven Dependency of mysql >> mysql-connector-java version5.0.4 in your project
Maven Dependency mysql-connector-java >> 5.0.5
You should include the dependency code given in this page to add Maven Dependency of mysql >> mysql-connector-java version5.0.5 in your project
Maven Dependency mysql-connector-java >> 5.0.7
You should include the dependency code given in this page to add Maven Dependency of mysql >> mysql-connector-java version5.0.7 in your project
Maven Dependency mysql-connector-java >> 5.0.8
You should include the dependency code given in this page to add Maven Dependency of mysql >> mysql-connector-java version5.0.8 in your project
Maven Dependency mysql-connector-java >> 5.1.1
You should include the dependency code given in this page to add Maven Dependency of mysql >> mysql-connector-java version5.1.1 in your project

Ads