英文:
Creating a test app to store first name, last name, username & password in to a db get odd results
问题
在运行应用程序时,我收到以下错误:
错误:
>com.mysql.jdbc.MysqlDataTruncation:数据截断:列 'password' 的数据过长,位于第1行
我将表从varchar (50)
更改为longText
,这解决了数据过长的问题。
结果(存储在数据库中):
javax.swing.JPasswordField[,150,137,239x28,layout=javax.swing.plaf.basic.BasicTextUI$UpdateHandler,alignmentX=0.0,alignmentY=0.0,border=javax.swing.plaf.synth.SynthBorder@171f498,flags=288,maximumSize=,minimumSize=,preferredSize=,caretColor=,disabledTextColor=DerivedColor(color=142,143,145 parent=nimbusDisabledText offsets=0.0,0.0,0.0,0 pColor=142,143,145,editable=true,margin=javax.swing.plaf.InsetsUIResource[top=0,left=0,bottom=0,right=0],selectedTextColor=DerivedColor(color=255,255,255 parent=nimbusSelectedText offsets=0.0,0.0,0.0,0 pColor=255,255,255,selectionColor=DerivedColor(color=57,105,138 parent=nimbusSelectionBackground offsets=0.0,0.0,0.0,0 pColor=57,105,138,columns=0,columnWidth=0,command=,horizontalAlignment=LEADING,echoChar=*]
结果存储在数据库中,而不是密码。
英文:
On running the app I get the following error:
Error:
>com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'password' at row 1
I changed the table from varchar (50)
to longText
which has cured the data too long for column.
Result (Stored in db):
javax.swing.JPasswordField[,150,137,239x28,layout=javax.swing.plaf.basic.BasicTextUI$UpdateHandler,alignmentX=0.0,alignmentY=0.0,border=javax.swing.plaf.synth.SynthBorder@171f498,flags=288,maximumSize=,minimumSize=,preferredSize=,caretColor=,disabledTextColor=DerivedColor(color=142,143,145 parent=nimbusDisabledText offsets=0.0,0.0,0.0,0 pColor=142,143,145,editable=true,margin=javax.swing.plaf.InsetsUIResource[top=0,left=0,bottom=0,right=0],selectedTextColor=DerivedColor(color=255,255,255 parent=nimbusSelectedText offsets=0.0,0.0,0.0,0 pColor=255,255,255,selectionColor=DerivedColor(color=57,105,138 parent=nimbusSelectionBackground offsets=0.0,0.0,0.0,0 pColor=57,105,138,columns=0,columnWidth=0,command=,horizontalAlignment=LEADING,echoChar=*]
The resulting is stored in the db and not the password
答案1
得分: 0
已解决:
犯的错误在于我的代码。我最初错误地将 ps.setString(4, newAccPass.toString());
放在了 ps.setString(4, String.valueOf(newAccPass.getPassword()));
的位置。
英文:
Resolved:
The mistake made was within my code. I had originally put ps.setString(4, newAccPass.toString()); in stead off ps.setString(4, String.valueOf(newAccPass.getPassword()));
专注分享java语言的经验与见解,让所有开发者获益!
评论