I get this error in my Java programme which coded by me according to a tutorial.I coded it to connect my Java App with MySql database.This is the code.
package Gui;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.SQLException;
/**
*
*
*/
public class connectionconfig
{
private connectionconfig()
{
Connection con=null;
try{
Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection("jdbc:mysql://localhost:3307/musicdb","","pro");
}catch(SQLException ex){
ex.printStackTrace();
}catch(ClassNotFoundException ex){
ex.printStackTrace();
}
}
public static void main(String args[])throws Exception{
Connection connection=getConnection();
Statement st=null;
ResultSet rs=null;
try{
st=connection.createStatement("");
rs=st.executeQuery("select count(*) from musicdata");
rs.next();
int musicCount=rs.getInt(1);
System.out.println("Music Count:"+musicCount);
}finally{
if(st!=null){
st.close();
}
if(rs!=null)
{
rs.close();
}
if(connection!=null)
{
try
{
connection.close ();
System.out.println ("Database connection terminated");
}
catch (Exception ex) { /* ignore close errors */ }
}
}
}
}
i get error in "Connection connection=getConnection();" and "st=connection.createStatement("");" statements
Plz help me......