Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Database/JDBC/SQL/JDO/Hibernate » MySQL  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 Re:急询:如何将数组插入到数据库中 [Re:why]
wewe8866





发贴: 17
积分: 0
于 2006-11-09 11:15 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
why wrote:
Write your own simple String arrayToString(int[]) and int[] stringToArray(String) helper methods (assume you have an int array to store), e.g.

StringBuffer sb = new StringBuffer();
String delimiter = "#";
for (int i = 1; i < intArray.length; i++) {
sb.append(int).append(delimiter);
}
retrun sb.toString();

string[] strArray= str.split(delimiter);
int[] intArray = new int[strArray.length];
for (int i = 1; i < strArray.length; i++) {
intArray[i] = Integer.parseInt(strArray[i]);
}
return intArray;


这方法不错,存进去了,不过长度有些长,我的串竟有840字节,还没进行读操作,我数据库用的text类型存储。
谢谢why~


wewe8866 edited on 2006-11-09 18:40

失败是成功之母,逃避失败,也就拒绝了成功~!

话题树型展开
人气 标题 作者 字数 发贴时间
18437 急询:如何将数组插入到数据库中 wewe8866 164 2006-11-04 21:36
15133 Re:急询:如何将数组插入到数据库中 why 147 2006-11-06 08:22
14989 Re:急询:如何将数组插入到数据库中 wewe8866 60 2006-11-06 09:59
14962 Re:急询:如何将数组插入到数据库中 why 620 2006-11-07 18:43
15103 Re:急询:如何将数组插入到数据库中 alix1997 22 2006-11-07 23:29
14909 Re:急询:如何将数组插入到数据库中 why 141 2006-11-08 19:23
16134 Re:急询:如何将数组插入到数据库中 wewe8866 620 2006-11-09 11:15

flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923