-
Bug
-
Resolution: Fixed
-
P2
-
1.1.4, 1.2.0
-
1.2fcs
-
x86
-
generic, windows_95
-
Not verified
Name: rm29839 Date: 11/24/97
I get fllowing message while my program executing
----------Message----------------
sun.io.MalformedInputException: Missing byte-order mark
sun.io.MalformedInputException: Missing byte-order mark
sun.io.MalformedInputException: Missing byte-order mark
java.lang.InternalError: Converter malfunction (Unicode) -- please submit a bug
report via http://java.sun.com/cgi-bin/bugreport.cgi
at java.io.InputStreamReader.malfunction(InputStreamReader.java:119)
at java.io.InputStreamReader.convertInto(InputStreamReader.java:133)
at java.io.InputStreamReader.fill(InputStreamReader.java:177)
at java.io.InputStreamReader.read(InputStreamReader.java:235)
at java.io.BufferedReader.fill(BufferedReader.java:144)
at java.io.BufferedReader.readLine(BufferedReader.java:232)
at Framej.appendStringToTextArea(simpleselect.java:249)
at simpleselect.main(simpleselect.java:68)
--------------------------------------------------
The program which make error is listed bellow..
Database via ODBC have Shift-JIS Japanese characters.
---------------Program----------------------------
import java.net.URL;
import java.sql.*;
import java.awt.*;
import java.io.*;
import java.util.*;
//import J2U;
class simpleselect {
static Framej FF;
public static void main (String args[]) {
FF = new Framej("ƒeƒXƒg");
FF.setSize( 300, 300 );
FF.show();
// FF.appendStringToTextArea("“ú–{Œêˆ—\n");
String url = "jdbc:odbc:Select.mdb";
String query = "SELECT * FROM Table1";
try {
// Load the jdbc-odbc bridge driver
Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
// Attempt to connect to a driver. Each one
// of the registered drivers will be loaded until
// one is found that can process this URL
Connection con = DriverManager.getConnection (
url, "Hiroki", "Hiroki");
// If we were unable to connect, an exception
// would have been thrown. So, if we get here,
// we are successfully connected to the URL
// Check for, and display and warnings generated
// by the connect.
checkForWarning (con.getWarnings ());
// Get the DatabaseMetaData object and display
// some information about the connection
DatabaseMetaData dma = con.getMetaData ();
FF.appendStringToTextArea("\nConnected to " + dma.getURL());
FF.appendStringToTextArea("\nDriver " + dma.getDriverName());
FF.appendStringToTextArea("\nVersion " + dma.getDriverVersion());
FF.appendStringToTextArea("\n");
// System.out.println("\nConnected to " + dma.getURL());
// System.out.println("Driver " + dma.getDriverName());
// System.out.println("Version " + dma.getDriverVersion());
// System.out.println("");
// Create a Statement object so we can submit
// SQL statements to the driver
Statement stmt = con.createStatement ();
// Submit a query, creating a ResultSet object
ResultSet rs = stmt.executeQuery (query);
// Display all columns and rows from the result set
dispResultSet (rs);
// Close the result set
rs.close();
// Close the statement
stmt.close();
// Close the connection
con.close();
}
catch (SQLException ex) {
// A SQLException was generated. Catch it and
// display the error information. Note that there
// could be multiple error objects chained
// together
System.out.println ("\n*** SQLException caught ***\n");
while (ex != null) {
System.out.println ("SQLState: " +
ex.getSQLState ());
System.out.println ("Message: " +
ex.getMessage ());
FF.appendStringToTextArea("Message: " + ex.getMessage ());
System.out.println ("Vendor: " +
ex.getErrorCode ());
ex = ex.getNextException ();
System.out.println ("");
}
}
catch (java.lang.Exception ex) {
// Got some other type of exception. Dump it.
ex.printStackTrace ();
}
}
//-------------------------------------------------------------------
// checkForWarning
// Checks for and displays warnings. Returns true if a warning
// existed
//-------------------------------------------------------------------
private static boolean checkForWarning (SQLWarning warn)
throws SQLException
{
boolean rc = false;
// If a SQLWarning object was given, display the
// warning messages. Note that there could be
// multiple warnings chained together
if (warn != null) {
System.out.println ("\n *** Warning ***\n");
rc = true;
while (warn != null) {
System.out.println ("SQLState: " +
warn.getSQLState ());
System.out.println ("Message: " +
warn.getMessage ());
System.out.println ("Vendor: " +
warn.getErrorCode ());
System.out.println ("");
warn = warn.getNextWarning ();
}
}
return rc;
}
//-------------------------------------------------------------------
// dispResultSet
// Displays all columns and rows in the given result set
//-------------------------------------------------------------------
private static void dispResultSet (ResultSet rs)
throws SQLException
{
int i;
// Get the ResultSetMetaData. This will be used for
// the column headings
ResultSetMetaData rsmd = rs.getMetaData ();
// Get the number of columns in the result set
int numCols = rsmd.getColumnCount ();
// Display column headings
for (i=1; i<=numCols; i++) {
if (i > 1) FF.appendStringToTextArea(",");
FF.appendStringToTextArea(rsmd.getColumnLabel(i));
// if (i > 1) System.out.print(",");
// System.out.print(rsmd.getColumnLabel(i));
}
FF.appendStringToTextArea("\n");
// System.out.println("");
// Display data, fetching until end of the result set
while (rs.next ()) {
// Loop through each column, getting the
// column data and displaying
for (i=1; i<=numCols; i++) {
// if (i > 1) System.out.print(",");
if (i > 1) FF.appendStringToTextArea(",");
// System.out.print(rs.getString(i));
FF.appendStringToTextArea(rs.getString(i));
}
FF.appendStringToTextArea("\n");
// System.out.println("");
// Fetch the next result set row
}
}
}
class Framej extends Frame {
private TextArea Message;
public Framej(String Title){
super(Title);
Message = new TextArea(10,31);
add(Message);
}
public void appendStringToTextArea(String string){
String sstring = "x";
byte ss[] = null;
// J2U j2u = new J2U();
// String sstring = j2u.Sjis_to_Uni(string);
try{
ss = string.getBytes();
// ByteArrayOutputStream OS = new ByteArrayOutputStream(50);
// OutputStreamWriter OSW = new OutputStreamWriter(OS);
// OSW.write(string, 0, string.length());
// OSW.close();
// ss = OS.toByteArray();
ByteArrayInputStream BAIS = new ByteArrayInputStream(ss);
InputStreamReader ISR = new InputStreamReader(BAIS, "Unicode");
BufferedReader BR = new BufferedReader(ISR);
sstring = BR.readLine();
BR.close();
System.out.println(sstring);
}catch(java.io.IOException e){
System.out.println(e);
}
Message.setFont(new Font("Dialog", Font.PLAIN, 12));
// Message.setForeground(Color.black);
// Message.append(sstring);
}
}
------------------------------------------------
(Review ID: 20499)
======================================================================
- duplicates
-
JDK-4162516 Only the first char is transferred from native to JVM-TextField
-
- Closed
-
- relates to
-
JDK-4189026 Dragging Unicode into Word leaves bad character
-
- Closed
-