ZagorTenay
Programmer
I am trying to connect to mssql database. The error I receive is,
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
at Baglanti.main(Baglanti.java:12)
Here is the code.. (This is my first code so I have no idea what is happenning)
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
/**import net.sourceforge.jtds.jdbc.Driver;*/
public class Baglanti {
public static void main(String[] args) throws Exception
{
// TODO Auto-generated method stub
try{
/**Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");*/
Class.forName("net.sourceforge.jtds.jdbc.Driver");
Connection conn;
conn=DriverManager.getConnection("jdbc:jtds:sqlserver://192.168.0.2:1433;DatabaseName=cari2;User=usr1;Passwd=");
/**conn=DriverManager.getConnection("jdbcdbc:cari2","usr1","");*/
System.out.println(conn.getClass());
Statement query=conn.createStatement();
ResultSet veriler=query.executeQuery("SELECT * FROM Bankalar");
System.out.println("Baglanti kapali: " + conn.isClosed());
System.out.println ("Banka listesi:");
while (veriler.next());
{System.out.println (veriler.getString("Banka"));}
veriler.close();
conn.close();
}
catch (Exception e)
{System.out.println("Hata!!!");}
}
}
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
at Baglanti.main(Baglanti.java:12)
Here is the code.. (This is my first code so I have no idea what is happenning)
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
/**import net.sourceforge.jtds.jdbc.Driver;*/
public class Baglanti {
public static void main(String[] args) throws Exception
{
// TODO Auto-generated method stub
try{
/**Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");*/
Class.forName("net.sourceforge.jtds.jdbc.Driver");
Connection conn;
conn=DriverManager.getConnection("jdbc:jtds:sqlserver://192.168.0.2:1433;DatabaseName=cari2;User=usr1;Passwd=");
/**conn=DriverManager.getConnection("jdbcdbc:cari2","usr1","");*/
System.out.println(conn.getClass());
Statement query=conn.createStatement();
ResultSet veriler=query.executeQuery("SELECT * FROM Bankalar");
System.out.println("Baglanti kapali: " + conn.isClosed());
System.out.println ("Banka listesi:");
while (veriler.next());
{System.out.println (veriler.getString("Banka"));}
veriler.close();
conn.close();
}
catch (Exception e)
{System.out.println("Hata!!!");}
}
}