将治疗结果存储在表格中(store the results of a treatment in table)
我执行了一个代码,用于显示来自“update_action”列中字段内容的指定信息,表格“事件”是WampServer上的数据库“base_rapport_tt”。 在我的表格中,我添加了另一列,我将在其中存储显示的信息。 我的目标是显示整列的结果并将其存储在新的列顺序中。
try { String Sql="Select Update_Action from incident where id_incident ='"+jTextField3.getText()+"' and Status like 'Closed'"; con = getConnection("jdbc:mysql://localhost:3306/base_rapport_tt","root",""); stmt=con.createStatement(); rs=stmt.executeQuery(Sql); while(rs.next()) { str=rs.getString("update_Action"); while(!"".equals(str)){ int debut=str.indexOf('(')+1; int fin=str.indexOf(')',debut); nom += " "+str.substring(debut,fin); str=str.substring(fin+1,str.length()); nom+=", "; } } } catch (Exception e) { JOptionPane.showMessageDialog(this,e); }
我尝试使用此代码:
try { String Sql="Select Update_Action,id_incident from incident where Status like 'Closed'"; con = getConnection("jdbc:mysql://localhost:3306/base_rapport_tt","root",""); stmt=con.createStatement(); rs=stmt.executeQuery(Sql); while(rs.next()) { str=rs.getString("update_Action"); nom=""; while(!"".equals(str)){ int debut=str.indexOf('(')+1; int fin=str.indexOf(')',debut); nom += " "+str.substring(debut,fin); str=str.substring(fin+1,str.length()); nom+=", "; Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/base_rapport_tt", "root", ""); String query = "update incident set intervenants = ? where id_incident like '%'"; java.sql.PreparedStatement preparedStmt = conn.prepareStatement(query); preparedStmt.setString(1,nom); preparedStmt.executeUpdate(); conn.close(); } } } catch (Exception e) { //JOptionPane.showMessageDialog(this,e); }
收件人字段的第一列的结果很好。 但问题是其他领域是前者的结果。
谢谢。
I executed a code that is used to display the specified information from a content of a field in a column "update_action" a table "incident" a database "base_rapport_tt" on WampServer. and in my table, I added another column in which I will store the displayed information. My goal is to display the result of the whole column and store it in the new column order.
try { String Sql="Select Update_Action from incident where id_incident ='"+jTextField3.getText()+"' and Status like 'Closed'"; con = getConnection("jdbc:mysql://localhost:3306/base_rapport_tt","root",""); stmt=con.createStatement(); rs=stmt.executeQuery(Sql); while(rs.next()) { str=rs.getString("update_Action"); while(!"".equals(str)){ int debut=str.indexOf('(')+1; int fin=str.indexOf(')',debut); nom += " "+str.substring(debut,fin); str=str.substring(fin+1,str.length()); nom+=", "; } } } catch (Exception e) { JOptionPane.showMessageDialog(this,e); }
I tried with this code:
try { String Sql="Select Update_Action,id_incident from incident where Status like 'Closed'"; con = getConnection("jdbc:mysql://localhost:3306/base_rapport_tt","root",""); stmt=con.createStatement(); rs=stmt.executeQuery(Sql); while(rs.next()) { str=rs.getString("update_Action"); nom=""; while(!"".equals(str)){ int debut=str.indexOf('(')+1; int fin=str.indexOf(')',debut); nom += " "+str.substring(debut,fin); str=str.substring(fin+1,str.length()); nom+=", "; Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/base_rapport_tt", "root", ""); String query = "update incident set intervenants = ? where id_incident like '%'"; java.sql.PreparedStatement preparedStmt = conn.prepareStatement(query); preparedStmt.setString(1,nom); preparedStmt.executeUpdate(); conn.close(); } } } catch (Exception e) { //JOptionPane.showMessageDialog(this,e); }
the result of the first column of the recipient field is well. But the problem is that the other fields is the result of the former.
thanks.
原文:https://stackoverflow.com/questions/29624134
最满意答案
print ('Test with data: ', args, ' failed result: ', result, ' answer: ', answer)
print ('Test with data: ', args, ' failed result: ', result, ' answer: ', answer)
相关问答
更多-
我在这里看到很多答案。 但是,我认为您尝试运行的文件不正确 C:\Python32\Pythonw.exe 不是你用来打开空闲的那个。 打开 C:\Python32\Lib\idlelib\idle.pyw I saw a lot of answers here. But, I think the file that you are trying to run is not correct C:\Python32\Pythonw.exe is not the one you use to open i ...
-
它应该是 print "My name is %s and my age is %d years old!" % ('Bob', 30) 抛出错误是因为它期望整数值为%d但得到字符串%s 但是int可以转换为字符串,因此以前的情况不受影响 it should be print "My name is %s and my age is %d years old!" % ('Bob', 30) The error was thrown because it expected integer value th ...
-
%g可能是您正在寻找的: >>> "%g, %g, %g, %g" % (2.1, 2.01, 2.001, 2.0001) '2.1, 2.01, 2.001, 2.0001' %g may be what you're looking for: >>> "%g, %g, %g, %g" % (2.1, 2.01, 2.001, 2.0001) '2.1, 2.01, 2.001, 2.0001'
-
打印unicode字符串在python 3.2中工作但在2.7中不能工作(Printing unicode string works in python 3.2 but not in 2.7)[2024-01-29]
请参阅文档中的 unicode_csv_reader() 。 作为替代方案,如果控制台理解utf-8并且除了将它们打印到控制台之外的其他项目上不进行任何文本处理,则可以跳过解码/编码: with open('07362853300091_trade_turquoise_errNo_031.csv', 'rb') as file: for row in csv.reader(file): print "\n".join(row) See unicode_csv_reader() ... -
print是 py3x中的一个函数 : print ('Test with data: ', args, ' failed result: ', result, ' answer: ', answer) print is a function in py3x: print ('Test with data: ', args, ' failed result: ', result, ' answer: ', answer)
-
打开文件时,您没有指定编码。 您需要在Python 3中执行此操作,因为在Python 3中,文本模式文件将返回已解码的Unicode字符串。 现在您尝试使用UTF-8,但这不起作用,显然,这不是使用的编码。 只有你知道它是什么编码,但我猜它是cp1252,因为0x80是代码页的字符为€,所以当你有欧洲Windows用户时,在0x80上失败很常见。 :-) 为了与Python 2.7和3.1兼容,我建议您使用io库打开文件。 这是默认情况下在Python 3中使用的那个,它也可以在Python 2.6及更高 ...
-
要将百分比包含到将用于printf样式字符串格式的字符串中,只需通过包含一个双%%百分比%% a = [] b = {'by_name': "FTa0213"} a.append(" name like %%%s' " % b['by_name']) print "a :", a ( 文档 ) To include a percent % into a string which will be used for a printf style string format, simply escape the ...
-
codecs.utf_8_decode(input.encode('utf8')) codecs.utf_8_decode(input.encode('utf8'))
-
当我安装2.7.13时,在另一个模块中有类似的问题。 恢复到2.7.12(赢得7位64位的32位)问题消失了。 Had similar issues in another module when I installed 2.7.13. Reverted to 2.7.12 (32bit on win 7 64bit) and the problem went away.
-
我的建议是使用格式方法,这将消除与%的部分误解。 例如: myStr = '{0} int and {1} string and {2} list...' mystr.format(10, 'string value', range(10) 如果您仍需要使用%表示法,请仔细阅读以下链接: http : //docs.python.org/2/library/stdtypes.html#string-formatting-operations 认为你只是使用不正确的转换。 根据您的样本: def print ...