Java Reference
In-Depth Information
1
2
public class
Errors
implements
Serializable
3
{
4
private
Connection
con =
null
;
5
6
public
Errors
()
throws
ClassNotFoundException
,
SQLException
7
{
8
String
url =
"jdbc:odbc:StockTracker"
;
9
Class
.forName
(
"sun.jdbc.odbc.JdbcOdbcDriver"
)
;
10
con =
DriverManager
.getConnection
(
url
)
;
11
}
12
13
public byte
[]
serializeObj
(
Object
obj
)
throws
IOException
14
{
15
ByteArrayOutputStream
baOStream =
new
ByteArrayOutputStream
()
;
16
ObjectOutputStream
objOStream =
new
ObjectOutputStream
(
baOStream
)
;
17
18
objOStream.writeObject
(
obj
)
;
19
objOStream.flush
()
;
20
objOStream.close
()
;
21
return
baOStream.toByteArray
()
;
22
}
23
24
25
(a)
1 A:\Chapter11\Errors.java:2: cannot resolve symbol
2 symbol : class Serializable
3 location: class Errors
4 public class Errors implements Serializable
5 ^
6 A:\Chapter11\Errors.java:4: cannot resolve symbol
7 symbol : class Connection
8 location: class Errors
9 private Connection con = null;
10 ^
11 A:\Chapter11\Errors.java:6: cannot resolve symbol
12 symbol : class SQLException
13 location: class Errors
14 public Errors() throws ClassNotFoundException,SQLException
15 ^
16 A:\Chapter11\Errors.java:13: cannot resolve symbol
17 symbol : class IOException
18 location: class Errors
19 public byte[] serializeObj(Object obj) throws IOException
20 ^
21 A:\Chapter11\Errors.java:10: cannot resolve symbol
22 symbol : variable DriverManager
23 location: class Errors
24 con = DriverManager.getConnection(url);
25 ^
26 A:\Chapter11\Errors.java:15: cannot resolve symbol
27 symbol : class ByteArrayOutputStream
28 location: class Errors
29 ByteArrayOutputStream baOStream = new
ByteArrayOutputStream();
30 ^
31 A:\Chapter11\Errors.java:15: cannot resolve symbol
32 symbol : class ByteArrayOutputStream
33 location: class Errors
34
ByteArrayOutputStream baOStream = new
ByteArrayOutputStream();
35
^
36 A:\Chapter11\Errors.java:16: cannot resolve symbol
37 symbol : class ObjectOutputStream
38 location: class Errors
39 ObjectOutputStream objOStream = new ObjectOutputStream(baOStream);
40 ^
41 A:\Chapter11\Errors.java:16: cannot resolve symbol
42 symbol : class ObjectOutputStream
43 location: class Errors
44
ObjectOutputStream objOStream = new ObjectOutputStream(baOStream);
45
^
46 9 errors
47
48 Tool completed with exit code 1
49
(b)
FIGURE 11-78
Search WWH ::
Custom Search