Android listview unfortunately has stopped hatasi
merhaba arkadaslar. Sql Server veritabanindaki verilerimi listview ile goslermek istiyorum. bunun icin String dizi donduren method yazdim ve. bu methodun degerlerini String diziye artardim. bi diziyi Adapter ile Listview ile birlesdirdim ama uygulamayi calisdirdigimda "unfortunately has stopped" hatasi geliyor. Nerde hata yapmisim bulamiyorum. yardim edin bir zahmet.
Connection.java
[code]
package com.nursultan.borc_al;
import java.sql.DriverManager;
import java.sql.DriverPropertyInfo;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;
import net.sourceforge.jtds.jdbc.Driver;
public class Connection {
private java.sql.Connection baglanti;
private Statement statement;
private ResultSet rs;
public Connection(){
try {
DriverManager.registerDriver(new Driver());
baglanti = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;databaseName=test1;user=example;password=***********;");
statement = baglanti.createStatement();
} catch (Exception e) {
e.printStackTrace();
}
}
private int borcumAdiCount(){
int count = 0;
try {
String sql = "SELECT count(*) from ExampleDB.dbo.tbl_borclarim";
rs = statement.executeQuery(sql);
if(rs.next()){
count = rs.getInt(1);
}
return count;
} catch (Exception e) {
e.printStackTrace();
return 0;
}
}
public String[] borcAdi(){
String arrayBorcumAdi[] = new String[borcumAdiCount()];
try {
String adSql = "SELECT * from ExampleDB.dbo.tbl_borclarim";
rs = statement.executeQuery(adSql);
int i =0;
while(rs.next()){
String array_borcum = rs.getString("borcum");
arrayBorcumAdi [i] = array_borcum;
i++;
}
} catch (Exception e) {
e.printStackTrace();
}
return arrayBorcumAdi;
}
private int borcumCount(){
int count = 0;
try {
String sql = "SELECT count(*) from ExampleDB.dbo.tbl_borclarim";
rs = statement.executeQuery(sql);
if(rs.next()){
count = rs.getInt(1);
}
return count;
} catch (Exception e) {
e.printStackTrace();
return 0;
}
}
public String[] borcum(){
String arrayBorcum[] = new String[borcumCount()];
try {
String borcSql = "SELECT * from ExampleDB.dbo.tbl_borclarim";
rs = statement.executeQuery(borcSql);
int i =0;
while(rs.next()){
String array_borcum = rs.getString("borclarim_adi");
arrayBorcum [i] = array_borcum;
i++;
}
} catch (Exception e) {
e.printStackTrace();
return null;
}
return arrayBorcum;
}
}
[/code]
Borclarim.java
[code]
package com.nursultan.borc_al;
import java.sql.DriverManager;
import java.sql.DriverPropertyInfo;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;
import net.sourceforge.jtds.jdbc.Driver;
public class Connection {
private java.sql.Connection baglanti;
private Statement statement;
private ResultSet rs;
public Connection(){
try {
DriverManager.registerDriver(new Driver());
baglanti = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;databaseName=ExampleDB;user=example;password=root;");
statement = baglanti.createStatement();
} catch (Exception e) {
e.printStackTrace();
}
}
private int borcumAdiCount(){
int count = 0;
try {
String sql = "SELECT count(*) from ExampleDB.dbo.tbl_borclarim";
rs = statement.executeQuery(sql);
if(rs.next()){
count = rs.getInt(1);
}
return count;
} catch (Exception e) {
e.printStackTrace();
return 0;
}
}
public String[] borcAdi(){
String arrayBorcumAdi[] = new String[borcumAdiCount()];
try {
String adSql = "SELECT * from ExampleDB.dbo.tbl_borclarim";
rs = statement.executeQuery(adSql);
int i =0;
while(rs.next()){
String array_borcum = rs.getString("borcum");
arrayBorcumAdi [i] = array_borcum;
i++;
}
} catch (Exception e) {
e.printStackTrace();
}
return arrayBorcumAdi;
}
private int borcumCount(){
int count = 0;
try {
String sql = "SELECT count(*) from ExampleDB.dbo.tbl_borclarim";
rs = statement.executeQuery(sql);
if(rs.next()){
count = rs.getInt(1);
}
return count;
} catch (Exception e) {
e.printStackTrace();
return 0;
}
}
public String[] borcum(){
String arrayBorcum[] = new String[borcumCount()];
try {
String borcSql = "SELECT * from ExampleDB.dbo.tbl_borclarim";
rs = statement.executeQuery(borcSql);
int i =0;
while(rs.next()){
String array_borcum = rs.getString("borclarim_adi");
arrayBorcum [i] = array_borcum;
i++;
}
} catch (Exception e) {
e.printStackTrace();
return null;
}
return arrayBorcum;
}
}
[/code]