Frage

I am trying to rewrite some java code to Xtend however I am running into an issue. I would like to connect to a mysql database.

try {

  Class.forName("com.mysql.jdbc.Driver");
}catch(Exception e){
}

The above snippet works in Java. However I am trying to learn Xtend and figure out how the Class.forName should be done in Extend. Xtend cannot seem to find the "Class" or method "forName"

The error message I get from Eclipse is "This expression is not allowed in this context as it does not cause any side effect.

Anybody know what I am doing wrong. What is the Xtend syntax for connecting to a database?

War es hilfreich?

Lösung

The syntax to invoke static methods is Class::forName("com.mysql.jdbc.Driver"). Please refer to the docs for other syntactic hints to get familiar with Xtend.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top