请帮忙!
我使用jtds1.2.7.jar(1.2.5到1.2.8)连接我的SQL Server 2008R2并且它正常工作,直到我添加新的依赖关系到gradle编译(并且无关紧要什么类型的库)。我添加了一些布局和类后,我再次收到此错误...我没有更改我的代码,连接字符串,查询或其他任何内容。我不知道该怎么做。
这是我的代码:
class login extends AsyncTask<String, String, Integer> {
Integer mysession=0;
@Override
protected void onPostExecute(Integer i) {
Log.d("zxc","remember settings");
super.onPostExecute(i);
}
@Override
protected void onPreExecute() {
login_try++;
super.onPreExecute();
}
@Override
protected Integer doInBackground(String... params) {
MyApplication.MY_IP=MyApplication.getLocalIpAddress();
try {
Connection conn = null;
try
{
Class.forName("net.sourceforge.jtds.jdbc.Driver");
Log.d("zxc", "MSSQL connected");
Log.d("zxc", "MSSQL driver");
conn = DriverManager.getConnection(MyApplication.db_url, MyApplication.db_name, MyApplication.db_password );
Statement st = conn.createStatement();
Log.d("zxc", "good!");
String query = "DECLARE @code int,@code_name varchar(150),@id_session int,@Questions_xml xml, @JK_array xml, @My_info xml, @My_avatar nvarchar(max)" +
" EXEC [DS_CRM].[dbo].[Autorization_Revizor] @Login = N'" + MyApplication.MY_LOGIN + "', @Password = N'"+ MyApplication.MY_PASSWORD +"', @id_value_enter = 1, @IP = N'" + MyApplication.MY_IP + "', @Useragent = N'" + MyApplication.SOFTWAREVERSION + "', @Comment = N'IMEI:" + MyApplication.MYIMEI + "', @code = @code OUTPUT, @code_name = @code_name OUTPUT, @id_session = @id_session OUTPUT, @Questions_xml = @Questions_xml OUTPUT, @My_info = @My_info OUTPUT, @JK_array = @JK_array OUTPUT, @My_avatar=@My_avatar OUTPUT " +
" SELECT @code as N'code',@code_name as N'code_name', @id_session as N'id_session', @Questions_xml as N'Questions_xml', @My_info as N'My_info', @JK_array as N'JK_array', @My_avatar as N'My_avatar'";
catch (java.sql.SQLException e) { e.printStackTrace();
Log.d("zxc", "bad=" + e.toString()); resultcode="Не смог подключиться к БД"; } //HERE IS MY EXCEPTION!!!!!!!!
}
catch (Exception e) { e.printStackTrace(); resultcode="Не смог выполнить функцию запроса"; }
return mysession;
}
}
这是我的例外:
:52.422 15658-15763/ru.ds_exp.test_07042016_02 D/zxc: MSSQL connected
07-12 20:35:52.950 56-56/? D/Genymotion: Received Ping
07-12 20:35:53.054 15658-15659/ru.ds_exp.test_07042016_02 D/dalvikvm: GC_CONCURRENT freed 701K, 15% free 10351K/12167K, paused 19ms+12ms, total 52ms
07-12 20:35:53.890 15658-15659/ru.ds_exp.test_07042016_02 D/dalvikvm: GC_CONCURRENT freed 857K, 15% free 10945K/12871K, paused 13ms+37ms, total 177ms
07-12 20:35:54.950 56-56/? D/Genymotion: Received Ping
07-12 20:35:55.566 15658-15684/ru.ds_exp.test_07042016_02 I/GMPM: Tag Manager is not found and thus will not be used
07-12 20:35:55.862 15658-15763/ru.ds_exp.test_07042016_02 W/System.err: java.sql.SQLException: The executeQuery method must return a result set.
07-12 20:35:55.866 15658-15763/ru.ds_exp.test_07042016_02 W/System.err: at net.sourceforge.jtds.jdbc.JtdsStatement.executeSQLQuery(JtdsStatement.java:517)
07-12 20:35:55.874 15658-15763/ru.ds_exp.test_07042016_02 W/System.err: at net.sourceforge.jtds.jdbc.JtdsStatement.executeQuery(JtdsStatement.java:1433)
07-12 20:35:55.874 15658-15763/ru.ds_exp.test_07042016_02 W/System.err: at net.sourceforge.jtds.jdbc.ConnectionJDBC2.<init>(ConnectionJDBC2.java:401)
07-12 20:35:55.886 15658-15763/ru.ds_exp.test_07042016_02 W/System.err: at net.sourceforge.jtds.jdbc.Driver.connect(Driver.java:188)
07-12 20:35:55.886 15658-15763/ru.ds_exp.test_07042016_02 W/System.err: at java.sql.DriverManager.getConnection(DriverManager.java:175)
07-12 20:35:55.890 15658-15763/ru.ds_exp.test_07042016_02 W/System.err: at java.sql.DriverManager.getConnection(DriverManager.java:209)
07-12 20:35:55.894 15658-15763/ru.ds_exp.test_07042016_02 W/System.err: at ru.ds_exp.test_07042016_02.Screen_1$login.doInBackground(Screen_1.java:1072)
07-12 20:35:55.894 15658-15763/ru.ds_exp.test_07042016_02 W/System.err: at ru.ds_exp.test_07042016_02.Screen_1$login.doInBackground(Screen_1.java:1044)
07-12 20:35:55.906 15658-15763/ru.ds_exp.test_07042016_02 W/System.err: at android.os.AsyncTask$2.call(AsyncTask.java:287)
07-12 20:35:55.934 15658-15763/ru.ds_exp.test_07042016_02 W/System.err: at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
07-12 20:35:55.946 15658-15763/ru.ds_exp.test_07042016_02 W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:137)
07-12 20:35:55.966 15658-15763/ru.ds_exp.test_07042016_02 W/System.err: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
07-12 20:35:55.966 15658-15763/ru.ds_exp.test_07042016_02 W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
07-12 20:35:55.978 15658-15763/ru.ds_exp.test_07042016_02 W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
07-12 20:35:55.994 15658-15763/ru.ds_exp.test_07042016_02 W/System.err: at java.lang.Thread.run(Thread.java:856)
07-12 20:35:55.994 15658-15763/ru.ds_exp.test_07042016_02 D/zxc: bad=The executeQuery method must return a result set.
07-12 20:35:56.026 15658-15658/ru.ds_exp.test_07042016_02 D/zxc: remember settings