jvilla1983
asked on
MYSQL/JAVA.. Data too long for column 'HOSTNAME' at row 1
Hi,
I keep getting the error..
Exception in thread "main" java.sql.SQLException: Data too long for column 'HOSTNAME' at row 1
even when I set my VARCHAR(50) and I know that I don't need THAT many characters. I was thinking it was because I had periods in the string, but that shouldn't matter should it?
Thanks in advance..
Here are my errors..
Exception in thread "main" java.sql.SQLException: Data too long for column 'HOSTNAME' at row 1
at com.mysql.jdbc.MysqlIO.che ckErrorPac ket(MysqlI O.java:200 1)
at com.mysql.jdbc.MysqlIO.sen dCommand(M ysqlIO.jav a:1168)
at com.mysql.jdbc.MysqlIO.sql QueryDirec t(MysqlIO. java:1279)
at com.mysql.jdbc.MysqlIO.sql Query(Mysq lIO.java:1 225)
at com.mysql.jdbc.Connection. execSQL(Co nnection.j ava:2278)
at com.mysql.jdbc.Connection. execSQL(Co nnection.j ava:2225)
at com.mysql.jdbc.Statement.e xecuteUpda te(Stateme nt.java:12 59)
at com.mysql.jdbc.Statement.e xecuteUpda te(Stateme nt.java:12 05)
at javaapplication6.PingDB.pu shDatabase (PingDB.ja va:88)
at javaapplication6.PingDB.ge nerateData base(PingD B.java:44)
at javaapplication6.Main.main (Main.java :33)
Java Result: 1
BUILD SUCCESSFUL (total time: 42 seconds)
I keep getting the error..
Exception in thread "main" java.sql.SQLException: Data too long for column 'HOSTNAME' at row 1
even when I set my VARCHAR(50) and I know that I don't need THAT many characters. I was thinking it was because I had periods in the string, but that shouldn't matter should it?
Thanks in advance..
Here are my errors..
Exception in thread "main" java.sql.SQLException: Data too long for column 'HOSTNAME' at row 1
at com.mysql.jdbc.MysqlIO.che
at com.mysql.jdbc.MysqlIO.sen
at com.mysql.jdbc.MysqlIO.sql
at com.mysql.jdbc.MysqlIO.sql
at com.mysql.jdbc.Connection.
at com.mysql.jdbc.Connection.
at com.mysql.jdbc.Statement.e
at com.mysql.jdbc.Statement.e
at javaapplication6.PingDB.pu
at javaapplication6.PingDB.ge
at javaapplication6.Main.main
Java Result: 1
BUILD SUCCESSFUL (total time: 42 seconds)
System.out.println(ComputerList.get(i).getHOSTNAME());
//Insert the record.
String pushNonExistant = "INSERT INTO pingresults VALUES('" + ComputerList.get(i).getIP_ADDR() +"','" +
ComputerList.get(i).getHOSTNAME() + "','" + ComputerList.get(i).getIS_ALIVE_String() + "','" +
ComputerList.get(i).getDATE()+ "')";
//This will run a push statement on to the database we select...
stmt.executeUpdate(pushNonExistant);
thats because your hostname is too long. check the hostname isn't padded
whats this display:
System.out.println(Compute rList.get( i).getHOST NAME().len gth());
whats this display:
System.out.println(Compute
ASKER
See, I did that.. and thought that might be the issue.. but I have VARCHAR(50) and it's just a little over 20 characters..
I apologize I can't give out the exact name of the server, but.. the structure is like this.
nameofserver.xx.yyyy.zzz
I apologize I can't give out the exact name of the server, but.. the structure is like this.
nameofserver.xx.yyyy.zzz
use the code i posted above to print exactly how long it is.
also make sure you have the columns in the correct order. Explicitly specify the column names is a better practice.
also make sure you have the columns in the correct order. Explicitly specify the column names is a better practice.
ASKER
22
ASKER
ok.. Something isn't right here..
I deleted the tables and then tried the program again and it's still acting as if there is a table, when there shouldn't be.
It's also referring to a table name I used earlier today which I changed a while back when I created the table.
I deleted the tables and then tried the program again and it's still acting as if there is a table, when there shouldn't be.
It's also referring to a table name I used earlier today which I changed a while back when I created the table.
check your connection string
ASKER
Exception in thread "main" java.sql.SQLException: Data too long for column 'HOSTNAME' at row 1
I'm still getting this when there isn't a table to query!!
and... I just dropped the database and it's still trying to query it! It's acting as if MYSQL is still providing it with a connection to that database and remembering the table I deleted.
I'm still getting this when there isn't a table to query!!
and... I just dropped the database and it's still trying to query it! It's acting as if MYSQL is still providing it with a connection to that database and remembering the table I deleted.
ASKER
My connection string is connecting to my MYSQL server. I know it works because I logged into my server and shut down MySQL. It didn't see the server then...
But when I turned it back on, it was the same thing going on.
But when I turned it back on, it was the same thing going on.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
DUDE.. YOU ARE A LIFESAVER!! you know how long I've been trying to get this D^@$ Database to work!!!
HAHAHA!!! Looks like I might be able to get some sleep tonight!
Tthanks a bunch!!
HAHAHA!!! Looks like I might be able to get some sleep tonight!
Tthanks a bunch!!
ASKER