0

I have to convert this code from Java to Scala:

 Connection connection = DriverManager.getConnection("jdbc: ...");
 OlapConnection olapConnection = connection.unwrap(OlapConnection.class);

Problem is to convert the unwrap parameter. This is my attempt in Scala:

val connection = DriverManager.getConnection("jdbc: ...")
val olapConnection = connection.unwrap(OlapConnection.getClass)

I get the error in OlapConnection.getClass :

value getClass is not a member of object org.olap4j.OlapConnection Note that OlapConnection extends Any, not AnyRef. Such types can participate in value classes, but instances cannot appear in singleton types or in reference comparisons.

What is the equivalent of the unwrap parameter in Scala?

0

1 Answer 1

2

The equivalent of Java's T.class in Scala would be classOf[T]:

val connection = DriverManager.getConnection("jdbc: ...")
val olapConnection = connection.unwrap(classOf[OlapConnection])

Note: not tested as I'm not sure what are your dependencies.

Sign up to request clarification or add additional context in comments.

1 Comment

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.