??xml version="1.0" encoding="utf-8" standalone="yes"?>国产精品免费久久久久,亚洲最大成人综合,中文字幕一区二区三区视频http://www.aygfsteel.com/banxitan/zh-cnWed, 18 Jun 2025 00:53:41 GMTWed, 18 Jun 2025 00:53:41 GMT60Android Activity MainThread 中不能执行http通信解决办法http://www.aygfsteel.com/banxitan/archive/2013/07/11/401439.htmlMikyTanMikyTanThu, 11 Jul 2013 02:51:00 GMThttp://www.aygfsteel.com/banxitan/archive/2013/07/11/401439.htmlhttp://www.aygfsteel.com/banxitan/comments/401439.htmlhttp://www.aygfsteel.com/banxitan/archive/2013/07/11/401439.html#Feedback0http://www.aygfsteel.com/banxitan/comments/commentRss/401439.htmlhttp://www.aygfsteel.com/banxitan/services/trackbacks/401439.html
android.os.NetworkOnMainThreadException

原因是Google?开始,强制默认止UIȝE发起通信h 

解决办法Q?strong> 

把通信的代码{Ud子线E里dQ?比较靠谱的是new一个AyncTaskQ在里面做通信

                          有几个细节性的问题是,

                                W一Q?一般原有通信的代码都是共通的APIQ?被许多个Activity调用Q?一个良好的修改Ҏ是在共通API里面new AyncTask

                               W二Q?通信的API一般来说都是同步的Q?你通信Q然后画面主U程需要堵塞住Q等待API的通信l果Q再军_下面的业务逻辑的走向?/strong>

所以,q块可以采取 AyncTask.get()Q?让主U程堵塞Q直到通信l束?当然Q如果你需要将通信异步的话Q?可以用Handler机制来解?br />

具体调用代码如下QHTTP?/strong>

步请?br />

package com.qqtech.ucstar.utils;

import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;

import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.mime.HttpMultipartMode;
import org.apache.http.entity.mime.MultipartEntity;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.impl.client.DefaultHttpClient;

import android.os.AsyncTask;

public class HttpReqTask extends AsyncTask<Object, Object, HttpResponse> {

@Override
protected HttpResponse doInBackground(Object arg0) {
String fileUploadUrl
= (String) arg0[0];
String streamid
= (String) arg0[1];
File file
= (File) arg0[2];
//boolean paramBoolean = Boolean.parseBoolean((String) arg0[3]);
//String paramString3 = (String) arg0[4];
HttpClient localHttpClient = new DefaultHttpClient();
//String str1 = "fileName";
File localFile = file;
try {
if ((localFile == null) || (!localFile.exists()))
throw new IOException("文g不存?" + localFile);
}
catch (IOException e1) {
e1.printStackTrace();
}

HttpPost localPostMethod
= new HttpPost(fileUploadUrl+"?streamid="+streamid+"&fileencode=UTF-8");
//MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE,null, Charset.forName("UTF-8"));
try {
FileBody bin
= new FileBody(file);
reqEntity.addPart(
"file", bin);
localPostMethod.setEntity(reqEntity);
HttpResponse response
= localHttpClient.execute(localPostMethod);
return response;
}
catch (Exception e) {
e.printStackTrace();
}

return null;
}


}



调用代码如下Q?br />

Object[] param = new Object[5];
     param[0] = answer.getUploadURL();
     param[1] = answer.getStreamid();
     param[2] = new File(answer.getFileURL());
     param[3] = "false";
     param[4] = "";
     AsyncTask res = new HttpReqTask().execute(param);
     HttpResponse rep = null;
     rep = (HttpResponse) res.get();
     if (rep.getStatusLine().getStatusCode() == 200) {
      System.out.println("文g上传成功");
     }else{
      System.out.println("文g上传p|");
     }
    }





MikyTan 2013-07-11 10:51 发表评论
]]>
修改模拟器DNSҎhttp://www.aygfsteel.com/banxitan/archive/2013/06/04/400196.htmlMikyTanMikyTanTue, 04 Jun 2013 12:24:00 GMThttp://www.aygfsteel.com/banxitan/archive/2013/06/04/400196.htmlhttp://www.aygfsteel.com/banxitan/comments/400196.htmlhttp://www.aygfsteel.com/banxitan/archive/2013/06/04/400196.html#Feedback0http://www.aygfsteel.com/banxitan/comments/commentRss/400196.htmlhttp://www.aygfsteel.com/banxitan/services/trackbacks/400196.html今天在做手机l端开发时Q发现连上域名服务器老是q不上,而直接用QPq接是OQ的Q初步怀凝是QNQ问题引hQ经查相关的资料Q现记录如下Q?br />
Android模拟器默认的地址?0.0.2.3Q默认的DNS也是10.0.2.3Q而一般电脑的IP都是192.168.1.100之类的,不在同一个网Dc所以就会出现电脑可以上|但是模拟器不能上网的情c其实设|方法很单,只要把模拟器的默认DNS讄成电脑的DNS地址卛_?/div>
W一步:用系l的命oq入Android开发包的tools目录
 cd X:\...\android-sdk-windows\tool
W二布:使用adb的shellQ确认系l的各项属?/div>
adb shell
getprop 
getprop会列出系l当前的各项属?/div>
W三步:得到模拟器的DNS地址
在结果里可以看到Q?/div>
[net.dns1]: [10.0.2.3]
[net.dns2]: [10.0.2.4]
[net.dns3]: [10.0.2.5]
[net.dns4]: [10.0.2.6]
W四步:把dnsҎ我们自己的DNS
setprop net.dns1 192.168.1.1


MikyTan 2013-06-04 20:24 发表评论
]]>JAVA q接 ORCLE RACq接URL?/title><link>http://www.aygfsteel.com/banxitan/archive/2013/05/21/399567.html</link><dc:creator>MikyTan</dc:creator><author>MikyTan</author><pubDate>Tue, 21 May 2013 08:48:00 GMT</pubDate><guid>http://www.aygfsteel.com/banxitan/archive/2013/05/21/399567.html</guid><wfw:comment>http://www.aygfsteel.com/banxitan/comments/399567.html</wfw:comment><comments>http://www.aygfsteel.com/banxitan/archive/2013/05/21/399567.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/banxitan/comments/commentRss/399567.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/banxitan/services/trackbacks/399567.html</trackback:ping><description><![CDATA[ q接的URL?br /><p><span style="color: rgb(255, 0, 0);">jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=vip1)(PORT</span></p><p><span style="color: rgb(255, 0, 0);">=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=vip2)(PORT=1521))(LOAD_BALANCE=yes)(FAILOVER=</span></p><p><span style="color: rgb(255, 0, 0);">on))(CONNECT_DATA=(SERVICE_NAME=gs))) </span></p><br /><img src ="http://www.aygfsteel.com/banxitan/aggbug/399567.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/banxitan/" target="_blank">MikyTan</a> 2013-05-21 16:48 <a href="http://www.aygfsteel.com/banxitan/archive/2013/05/21/399567.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Oralce 监听器启?/title><link>http://www.aygfsteel.com/banxitan/archive/2013/05/11/399145.html</link><dc:creator>MikyTan</dc:creator><author>MikyTan</author><pubDate>Sat, 11 May 2013 06:47:00 GMT</pubDate><guid>http://www.aygfsteel.com/banxitan/archive/2013/05/11/399145.html</guid><wfw:comment>http://www.aygfsteel.com/banxitan/comments/399145.html</wfw:comment><comments>http://www.aygfsteel.com/banxitan/archive/2013/05/11/399145.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/banxitan/comments/commentRss/399145.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/banxitan/services/trackbacks/399145.html</trackback:ping><description><![CDATA[<br />啟動      lsnrctl start<br />狀?nbsp;     lsnrctl status<br />關閉      lsnrctl  stop<img src ="http://www.aygfsteel.com/banxitan/aggbug/399145.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/banxitan/" target="_blank">MikyTan</a> 2013-05-11 14:47 <a href="http://www.aygfsteel.com/banxitan/archive/2013/05/11/399145.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Oracle 导出、导入某用户所有数据(包括表、视图、存储过E?..Q?/title><link>http://www.aygfsteel.com/banxitan/archive/2013/05/11/399134.html</link><dc:creator>MikyTan</dc:creator><author>MikyTan</author><pubDate>Sat, 11 May 2013 01:59:00 GMT</pubDate><guid>http://www.aygfsteel.com/banxitan/archive/2013/05/11/399134.html</guid><wfw:comment>http://www.aygfsteel.com/banxitan/comments/399134.html</wfw:comment><comments>http://www.aygfsteel.com/banxitan/archive/2013/05/11/399134.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/banxitan/comments/commentRss/399134.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/banxitan/services/trackbacks/399134.html</trackback:ping><description><![CDATA[<p><br /><span style="color: red"><strong>导出命oQexp </strong></span>用户?密码@数据?nbsp;owner=用户?nbsp;file=文g存储路径Q如QF:\abcd.dmpQ?br /></p> <p>试截图Qexp <a href="mailto:ZM/sql123@ORCL"><font color="#78afd3">ZM/sql123@ORCL</font></a> owner=ZM file=F\abcd.dmp<br /><img border="0" alt="" src="http://www.aygfsteel.com/images/blogjava_net/banxitan/导出.png" width="681" height="744" /><br /><br /><br /></p> <p><span style="color: red"><strong>导入命oQ?/strong></span>imp 用户?a href="mailto:cu/mycu@db"><font color="#78afd3">/密码@数据?/font></a> fromuser=用户?touser=用户?file=d:\cu.dmp ignore=y</p> <p> imp:命ocd  </p> <p><a href="mailto:cu/mycu@db"><font color="#78afd3">cu/mycu@db</font></a>:导入的数据库登陆(用户?密码@数据?  </p> <p>fromuser:文g的指定用?/p> <p> touserQ指定导入到当前d的数据库某个用户  </p> <p>file:需要导入的数据文g  </p> <p>ignore:是否忽略创徏错误</p> <p> </p> <p>试截图Q?br /><br />imp <a href="mailto:ZM/sql123@ORCL"><font color="#78afd3">ZM/sql123@ORCL</font></a> fromuser=ZM touser=SZZM file=F:\test.dmp ignore=y<br /><br /></p> <p><img border="0" alt="" src="http://www.aygfsteel.com/images/blogjava_net/banxitan/导入.png" /><br /><br /></p><br /><br /><img src ="http://www.aygfsteel.com/banxitan/aggbug/399134.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/banxitan/" target="_blank">MikyTan</a> 2013-05-11 09:59 <a href="http://www.aygfsteel.com/banxitan/archive/2013/05/11/399134.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>linux环境下的rmi常见问题http://www.aygfsteel.com/banxitan/archive/2013/05/08/399020.htmlMikyTanMikyTanWed, 08 May 2013 12:26:00 GMThttp://www.aygfsteel.com/banxitan/archive/2013/05/08/399020.htmlhttp://www.aygfsteel.com/banxitan/comments/399020.htmlhttp://www.aygfsteel.com/banxitan/archive/2013/05/08/399020.html#Feedback0http://www.aygfsteel.com/banxitan/comments/commentRss/399020.htmlhttp://www.aygfsteel.com/banxitan/services/trackbacks/399020.htmllinux环境下的rmi常见问题

问题一QRMI服务提供E序q行在Windows操作pȝ下,RMI服务可以正常讉KQ但RMI服务提供E序部v到Linux操作pȝ下后QRMI服务无法讉KQ提C?/p>

org.springframework.remoting.RemoteConnectFailureException:

Cannot connect to remote service [rmi://192.168.0.106:1199/ItemRetag]; nested exception is java.rmi.ConnectException: Connection refused to host: 127.0.0.1; ……   
 解决办法Q在加蝲RMI服务之前当前服务器的IP指定lhostNameQ如 System.setProperty("java.rmi.server.hostname", "192.168.100.7");或者修?etc/hosts文gQ在q个文g中加 192.168.100.54  testlinux1 localhost.localdomain localhost pQ或者将/etc/hosts文g中默认的127.0.0.1Ҏ当前机器的IP卛_Q?br />

问题二:java.rmi.server.ExportException: internal error: ObjID already in use Caused by: java.rmi.server.ExportException: internal error: ObjID already in use……

出现q种问题及有可能?etc/hosts文g中指定的IPq不是当前服务器的真实IPQRMI在初始化时注册服务失败?/p>

通过System.out.println(InetAddress.getLocalHost().toString());查看当前L的IP是否为真实IPQ如昄为SIMBANK/220.250.64.24Q而真实IP?92.168.1.2         

解决办法Q修?etc/hosts文g中错误的IP卛_Q将Q?/p>

220.250.64.24          SIMBANK
修改?/p>

192.168.1.2          SIMBANK



MikyTan 2013-05-08 20:26 发表评论
]]>
IBM JDK 、SUN JDK、HP JDK如何产生Heapdump文ghttp://www.aygfsteel.com/banxitan/archive/2013/03/26/397006.htmlMikyTanMikyTanTue, 26 Mar 2013 08:03:00 GMThttp://www.aygfsteel.com/banxitan/archive/2013/03/26/397006.htmlhttp://www.aygfsteel.com/banxitan/comments/397006.htmlhttp://www.aygfsteel.com/banxitan/archive/2013/03/26/397006.html#Feedback0http://www.aygfsteel.com/banxitan/comments/commentRss/397006.htmlhttp://www.aygfsteel.com/banxitan/services/trackbacks/397006.htmlJAVA中,通过分析Heapdump文g可以查程序是否存在内存泄Ԍ但是q个文g一般是在程序遇到致命问题时才会产生Q而如何事前生成这个文Ӟ从而在E序末崩溃前找出问题的所在?/span>

以下记述了各个版本的JDK产生DUMP文g的方法:

UN JDK生成Heapdump文g只需要在tomcat启动脚本中增?HeapDumpOnOutOfMemoryError 参数
此参数需要Java SE release 5.0 update 14 或以上支?/span>

讄CZ:
set JAVA_OPTS=%JAVA_OPTS% -server -Xms512m -Xmx800m -XX:PermSize=64M -XX:MaxPermSize=128m -Djava.awt.headless=true -XX:+HeapDumpOnOutOfMemoryError -XX:+HeapDumpOnCtrlBreak

IBM JDK生成Heapdump文g的开养I
— export IBM_HEAPDUMP=true
— export IBM_HEAP_DUMP=true
— export IBM_HEAPDUMP_OUTOFMEMORY=true
— export IBM_JAVADUMP_OUTOFMEMORY=true
— export IBM_JAVACORE_OUTOFMEMORY=true
— export IBM_HEAPDUMPDIR=<directory_path>

HP JDK生成Heapdump文g需要在在环境变量上Q加上export _JAVA_HEAPDUMP=1



MikyTan 2013-03-26 16:03 发表评论
]]>
MySql 的批量操作,要加rewriteBatchedStatements参数 http://www.aygfsteel.com/banxitan/archive/2013/03/13/396409.htmlMikyTanMikyTanWed, 13 Mar 2013 12:38:00 GMThttp://www.aygfsteel.com/banxitan/archive/2013/03/13/396409.htmlhttp://www.aygfsteel.com/banxitan/comments/396409.htmlhttp://www.aygfsteel.com/banxitan/archive/2013/03/13/396409.html#Feedback0http://www.aygfsteel.com/banxitan/comments/commentRss/396409.htmlhttp://www.aygfsteel.com/banxitan/services/trackbacks/396409.html今天在做某项目的POC试Q甲Ҏ供了一个三十万记录的TXT数据文gQ需要把该文件的记录插入到数据库中,׃目部的同事在搭建测试环境中用的是Mysql数据库,在把数据导入到数据库中用的是JDBC的批处理。代码如?
private void batchParseGroup(){
        Connection con
= null;
        PreparedStatement ps 
=null;
        
try {
            con
= DbConnectionManager.getConnection();
            con.setAutoCommit(
false);
            String sql 
= " insert into jivegroup(uri,groupname,pgroupid,description,creationdate,modificationdate,priority,selfpriority) values(?,?,?,?,?,?,?,?)";
            ps
= con.prepareStatement(sql);
            
for(int i=0;i<groupList.size();i++){
                Group group 
= groupList.get(i);
                ps.setString(
1, group.getUri());
                ps.setString(
2, group.getName());
                ps.setString(
3, group.getPgroupId());
                ps.setString(
4, group.getName());
                ps.setString(
5""+System.currentTimeMillis());
                ps.setString(
6""+System.currentTimeMillis());
                ps.setInt(
7, group.getPriority());
                ps.setInt(
8, group.getPriority());
                ps.addBatch();
                
if(i%100==0){
                    ps.executeBatch();
                }

            }

            con.commit();
            ps.executeBatch();
        }
 catch (SQLException e) {
            e.printStackTrace();
        }
finally{
            DbConnectionManager.closeConnection(ps, con);
        }

    }

在测试时Q发C十万的数据居焉要十分钟左右的时间。首先想到的是Mysql的相关配|是不是有问题,反复修改了Mysql的相应配|参敎ͼ收效甚微?br />
在Mysql的官|上查到如下Q?br /> http://dev.mysql.com/doc/refman/5.1/en/connector-j-reference-configuration-properties.html

关于rewriteBatchedStatements参数QMysql官方的说明:

Should the driver use multiqueries (irregardless of the setting of "allowMultiQueries") as well as rewriting of prepared statements for INSERT into multi-value inserts when executeBatch() is called? Notice that this has the potential for SQL injection if using plain java.sql.Statements and your code doesn't sanitize input correctly. Notice that for prepared statements, server-side prepared statements can not currently take advantage of this rewrite option, and that if you don't specify stream lengths when using PreparedStatement.set*Stream(), the driver won't be able to determine the optimum number of parameters per batch and you might receive an error from the driver that the resultant packet is too large. Statement.getGeneratedKeys() for these rewritten statements only works when the entire batch includes INSERT statements.



解决办法Q?br />      下蝲最新的JDBC的驱动程序?br />      MYSQL URL的配|参数如下:
      jdbc:mysql://54.200.190.80:3306/ccb_ucstar?rewriteBatchedStatements=true

l过试。三十多万的数据?0U内搞定Q?/div>

MikyTan 2013-03-13 20:38 发表评论
]]>
Linux 使用 enca 工具q行文g扚w格式转换http://www.aygfsteel.com/banxitan/archive/2012/09/17/387878.htmlMikyTanMikyTanMon, 17 Sep 2012 03:42:00 GMThttp://www.aygfsteel.com/banxitan/archive/2012/09/17/387878.htmlhttp://www.aygfsteel.com/banxitan/comments/387878.htmlhttp://www.aygfsteel.com/banxitan/archive/2012/09/17/387878.html#Feedback0http://www.aygfsteel.com/banxitan/comments/commentRss/387878.htmlhttp://www.aygfsteel.com/banxitan/services/trackbacks/387878.html
Q)下蝲enca工具
  wget http://dl.cihar.com/enca/enca-1.13.tar.gz
Q) tar -zxvf enca-1.13.tar.gz
Q)./configure
4) make
5) make install


转换命o
  enca -L zh_CN -x UTF-8 *.java




MikyTan 2012-09-17 11:42 发表评论
]]>
没有那个文g或目录”的解决Ҏhttp://www.aygfsteel.com/banxitan/archive/2012/08/18/385730.htmlMikyTanMikyTanSat, 18 Aug 2012 08:01:00 GMThttp://www.aygfsteel.com/banxitan/archive/2012/08/18/385730.htmlhttp://www.aygfsteel.com/banxitan/comments/385730.htmlhttp://www.aygfsteel.com/banxitan/archive/2012/08/18/385730.html#Feedback0http://www.aygfsteel.com/banxitan/comments/commentRss/385730.htmlhttp://www.aygfsteel.com/banxitan/services/trackbacks/385730.html如果sh目录存在且脚本无误,最可能是原因是在windows下写的脚本是dos格式的,攑֜Linux下编码不识别Q解x法是使用dos2unix命o转一下,卌入: dos2unix 文g?


MikyTan 2012-08-18 16:01 发表评论
]]> վ֩ģ壺 | | | | | ׸| | | »Ȱ| ϻ| | | Ҧ| | | ƺ| ƽ| ½| | Ϫ| ɽ| ɽ| ƽԭ| Ʊ| Ӣ| ī| | | | | | µ| | | | | | ˶| | | ͼ|