reset password
Author Message
lishenyu
Posts: 103
Posted 23:03 Nov 09, 2015 |

Hi Dr.Sun,

I have deleted the previous project and re-import SimpleDB project , but when I run it and no matter what query I typed , it still gave me NullPointerException :

SQL Exception: java.lang.NullPointerException
java.sql.SQLException: java.lang.NullPointerException
 at simpledb.remote.SimpleStatement.executeQuery(SimpleStatement.java:24)
 at simpledb.client.SQLInterpreter.doQuery(SQLInterpreter.java:48)
 at simpledb.client.SQLInterpreter.main(SQLInterpreter.java:26)
Caused by: java.lang.NullPointerException
 at simpledb.record.Schema.type(Schema.java:105)
 at simpledb.record.Schema.add(Schema.java:65)
 at simpledb.query.ProjectPlan.<init>(ProjectPlan.java:23)
 at simpledb.planner.BasicQueryPlanner.createPlan(BasicQueryPlanner.java:40)
 at simpledb.planner.Planner.createQueryPlan(Planner.java:29)
 at simpledb.remote.RemoteStatementImpl.executeQuery(RemoteStatementImpl.java:31)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:497)
 at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:323)
 at sun.rmi.transport.Transport$1.run(Transport.java:200)
 at sun.rmi.transport.Transport$1.run(Transport.java:197)
 at java.security.AccessController.doPrivileged(Native Method)
 at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
 at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)
 at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)
 at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$254(TCPTransport.java:683)
 at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler$$Lambda$1/739018661.run(Unknown Source)

could you help me solve this ?Thanks!

cysun
Posts: 2935
Posted 08:26 Nov 10, 2015 |

Did you create any table before trying to "select"?
 

lishenyu
Posts: 103
Posted 09:52 Nov 10, 2015 |

I just start the server first  then run the client , and in console it prompts to ask for SQL>  ,then I type easy query like "select id from students; " then this nullpointerexception occurs

cysun
Posts: 2935
Posted 09:55 Nov 10, 2015 |
lishenyu wrote:

I just start the server first  then run the client , and in console it prompts to ask for SQL>  ,then I type easy query like "select id from students; " then this nullpointerexception occurs

Sounds like you didn't create a students table or the students table didn't have a column id.

lishenyu
Posts: 103
Posted 10:11 Nov 10, 2015 |

isn't it that when we run the client ,it automaticly creates a student DB?  I need to create student DB? but yesterday I didn't create any tables , at first it can run the basic query but then for some reason ,it results in this exception.

lishenyu
Posts: 103
Posted 10:14 Nov 10, 2015 |

because I have seen code of CreateStudentDB in same folder in Client folder , so I think ,when we specify no arguments ,it will automatically create a StudentDB.

cysun
Posts: 2935
Posted 10:27 Nov 10, 2015 |

When you run the server, if no database exists, it will create an empty StudentDB.

There are several client programs. Read the code to see what each client does.