1. The connection was very slow, and an exception occurred while performing a select operation:
Exception in thread "main" java.sql.sqlexception:ora-00600: Internal error code, parameters: [ttcgcshnd-1], [0], [], [], [], [], [], []
Workaround: Normal after using the Jdbc\lib\classes12.jar under the Oracle installation directory.
2. Occurs when using the SetString (I, s) of PreparedStatement:
can refer to the post: http://community.csdn.net/Expert/topic/3936/3936672.xml?temp=.2879145
Java.sql.SQLException: Data size exceeds this type of maximum value: 3000
The value in the back is variable, and it's about the size of S.
Table structure
CREATE TABLE Test (
Name Char (32),
Addr varchar (3000)//VARCHAR2 as well
)
Solution: Adopt Setcharacterstream
-------------------------------------------------------
Import java.sql.*;
Import java.io.*
Import java.util.*
/**
* Oracle Test
* @author Kingfish
* @version 1.0
* *
public class Testora {
public static void Testoracle () {
String url = "Jdbc:oracle:thin: @localhost: 1521:oradb ";
String username = "System";
String Password = "Manager";
Connection conn = null;
try {
Class.forName ("Oracle.jdbc.driver.OracleDriver");
conn = drivermanager.getconnection (URL, username , password);
}
catch (Exception e) {
E.printstacktrace ();
return;
}
char[] CArray = new char[1000];
Arrays.fill (Carray,´ i ´);
String s = new string (CArray);
try {
PreparedStatement PST = conn.preparestatement (
INSERT INTO Test (NAME,ADDR) VALUES (?,?));
Pst.setstring (1, "Kingfish");
Pst.setcharacterstream (2,
New InputStreamReader (New Bytearrayinputstream (S.
GetBytes ()), s.length ());
Pst.setstring (2,s); The exception is
Pst.execute () in this sentence;
Statement st = Conn.createstatement ();
ResultSet r = st.executequery ("SELECT * from Test");
while (R.next ()) {
S = r.getstring (2);
System.out.println ("len=" + s.length ());
System.out.println ("value=" + s);
}
R.close ();
St.close ();
Conn.close ();
}
catch (Exception e) {
E.printstacktrace ();
}
}
/**
* Test
* @param args string[]
*/
public static void Main (string[] args) {
testoracle ();
}
}