Skip to content

Instantly share code, notes, and snippets.

@Suranchiyev
Suranchiyev / pom.xml
Created July 24, 2019 17:47
libraries for hsqldb
<!-- https://mvnrepository.com/artifact/org.hsqldb/hsqldb -->
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>2.5.0</version>
</dependency>
@Suranchiyev
Suranchiyev / pom.xml
Created July 24, 2019 17:47
libraries for hsqldb
<!-- https://mvnrepository.com/artifact/org.hsqldb/hsqldb -->
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>2.5.0</version>
</dependency>
@Suranchiyev
Suranchiyev / InMemoryStart.java
Created July 24, 2019 19:07
Java code start HSQLDB
import org.hsqldb.Server;
public class InMemoryStart {
public static void main(String[] args){
Server server = new Server();
server.setDatabaseName(0,"tmpDb");
server.setDatabasePath(0,"mem:tmpDb");
server.setPort(9001);
server.start();
}
@Suranchiyev
Suranchiyev / ConnectionToInMemoryDb.java
Last active July 24, 2019 19:42
Code to establish JDBC connection to in-memory db
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
public class ConnectionToInMemoryDb {
public static void main(String args[]){
try{
String url = "jdbc:hsqldb:hsql://localhost:9001/tmpDb; mem:tmpDb;";
String user = "SA";
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
public class StopInMemoryDb {
public static void main(String args[]){
try{
String url = "jdbc:hsqldb:hsql://localhost:9001/tmpDb; mem:tmpDb;";
String user = "SA";
String pass = "";

Special Characters 2

  • Program should display using only one print statement: Code Compiler JVM Output
  • Don't use regular space

Note:

  • You can use only one System.out.println() in this program
  • There is special character that represents new line/tab space
  • See how you can use \t

Variable Declaration

  • Write a program that declares in main method following variables:
    • name of type String
    • age of type int
    • cuty of type String

Variable Declaration

  • Write a program that declares in main method following variables:
    • name of type String
    • age of type int
    • city of type String

Comments in Java

  • Comment out extra lines that program will display:
    3 plus 4 equals 7
  • Do not comment variable declarations

Variables 1

  • Program should display:
    Output: 10
  • Do not change variable declarations in existing code:
  int a = 7;
  int b = 0;
  • Do not change print statement in existing code: