public class JdbcConnectionTest {
public static void main(String[] args) throws Exception {
// Dynamically loading the driver so that it will register.
Class.forName("oracle.jdbc.OracleDriver");
}
}
When I am running above code I am getting following exception:
Exception in thread "main" java.lang.ClassNotFoundException:
oracle.jdbc.OracleDriver at
java.net.URLClassLoader$1.run(URLClassLoader.java:372) at
java.net.URLClassLoader$1.run(URLClassLoader.java:361) at
java.security.AccessController.doPrivileged(Native Method) at
java.net.URLClassLoader.findClass(URLClassLoader.java:360) at
java.lang.ClassLoader.loadClass(ClassLoader.java:424) at
sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at
java.lang.ClassLoader.loadClass(ClassLoader.java:357) at
java.lang.Class.forName0(Native Method) at
java.lang.Class.forName(Class.java:260) at
JdbcConnectionTest.main(JdbcConnectionTest.java:14)
Please let me know if someone has a answer.
Try using the fully qualified class name :oracle.jdbc.driver.OracleDriver
Related
I have installed phoenix-5 on Hbase-2.2.2 and Hadoop-3.2.1 when I
create an index on a table, insertion time I get the following error. does
anybody know what the problem is?
try {
preparedStatement = connection.prepareStatement("create Index myIndex on city(name)");
preparedStatement.executeUpdate();
connection.commit();
} catch (Exception e) {
System.out.println(e.getMessage());
}
org.apache.hadoop.hbase.client.RetriesExhaustedWithDetailsException: Failed 1 action: org.apache.phoenix.hbase.index.builder.IndexBuildingFailureException: Failed to build index for unexpected reason!
at org.apache.phoenix.hbase.index.util.IndexManagementUtil.rethrowIndexingException(IndexManagementUtil.java:206)
at org.apache.phoenix.hbase.index.Indexer.preBatchMutate(Indexer.java:351)
at org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost$28.call(RegionCoprocessorHost.java:1019)
at org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost$28.call(RegionCoprocessorHost.java:1016)
at org.apache.hadoop.hbase.coprocessor.CoprocessorHost$ObserverOperationWithoutResult.callObserver(CoprocessorHost.java:551)
at org.apache.hadoop.hbase.coprocessor.CoprocessorHost.execOperation(CoprocessorHost.java:625)
at org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost.preBatchMutate(RegionCoprocessorHost.java:1016)
at org.apache.hadoop.hbase.regionserver.HRegion$MutationBatchOperation.prepareMiniBatchOperations(HRegion.java:3675)
at org.apache.hadoop.hbase.regionserver.HRegion.doMiniBatchMutate(HRegion.java:4091)
at org.apache.hadoop.hbase.regionserver.HRegion.batchMutate(HRegion.java:4045)
at org.apache.hadoop.hbase.regionserver.HRegion.batchMutate(HRegion.java:3976)
at org.apache.hadoop.hbase.regionserver.RSRpcServices.doBatchOp(RSRpcServices.java:1042)
at org.apache.hadoop.hbase.regionserver.RSRpcServices.doNonAtomicBatchOp(RSRpcServices.java:974)
at org.apache.hadoop.hbase.regionserver.RSRpcServices.doNonAtomicRegionMutation(RSRpcServices.java:937)
at org.apache.hadoop.hbase.regionserver.RSRpcServices.multi(RSRpcServices.java:2737)
at org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos$ClientService$2.callBlockingMethod(ClientProtos.java:42202)
at org.apache.hadoop.hbase.ipc.RpcServer.call(RpcServer.java:413)
at org.apache.hadoop.hbase.ipc.CallRunner.run(CallRunner.java:133)
at org.apache.hadoop.hbase.ipc.RpcExecutor$Handler.run(RpcExecutor.java:338)
at org.apache.hadoop.hbase.ipc.RpcExecutor$Handler.run(RpcExecutor.java:318)
Caused by: java.lang.VerifyError: class org.apache.phoenix.hbase.index.covered.data.IndexMemStore$1 overrides final method compare.(Lorg/apache/hadoop/hbase/Cell;Lorg/apache/hadoop/hbase/Cell;)I
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.apache.phoenix.hbase.index.covered.data.IndexMemStore.(IndexMemStore.java:82)
at org.apache.phoenix.hbase.index.covered.LocalTableState.(LocalTableState.java:57)
at org.apache.phoenix.hbase.index.covered.NonTxIndexBuilder.getIndexUpdate(NonTxIndexBuilder.java:52)
at org.apache.phoenix.hbase.index.builder.IndexBuildManager.getIndexUpdate(IndexBuildManager.java:90)
at org.apache.phoenix.hbase.index.Indexer.preBatchMutateWithExceptions(Indexer.java:503)
at org.apache.phoenix.hbase.index.Indexer.preBatchMutate(Indexer.java:348)
... 18 more
: 1 time, servers with issues: ubuntu,16020,1580881208169
here is my setup below,
#SpringBootApplication
#ComponentScan(basePackages = "com.amazonaws.serverless.sample.springboot.controller")
public class Application extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
public class LambdaHandler implements RequestStreamHandler {
private SpringBootLambdaContainerHandler<AwsProxyRequest, AwsProxyResponse> handler;
private static ObjectMapper mapper = new ObjectMapper();
private Logger log = LoggerFactory.getLogger(LambdaHandler.class);
#Override
public void handleRequest(InputStream inputStream, OutputStream outputStream, Context context)
throws IOException {
if (handler == null) {
try {
handler = SpringBootLambdaContainerHandler.getAwsProxyHandler(Application.class);
} catch (ContainerInitializationException e) {
e.printStackTrace();
outputStream.close();
return;
}
}
AwsProxyRequest request = mapper.readValue(inputStream, AwsProxyRequest.class);
AwsProxyResponse resp = handler.proxy(request, context);
mapper.writeValue(outputStream, resp);
// just in case it wasn't closed by the mapper
outputStream.close();
}
}
each time when when I am trying invoke my lambda from local console using command - "serverless invoke local -f hello" I am getting below exception,
j
ava.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.serverless.InvokeBridge.invoke(InvokeBridge.java:102)
at com.serverless.InvokeBridge.<init>(InvokeBridge.java:40)
at com.serverless.InvokeBridge.main(InvokeBridge.java:153)
Caused by: java.lang.NoClassDefFoundError: javax/servlet/ServletContainerInitializer
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at com.amazonaws.serverless.proxy.spring.SpringBootLambdaContainerHandler.initialize(SpringBootLambdaContainerHandler.java:167)
at com.amazonaws.serverless.proxy.spring.SpringBootLambdaContainerHandler.getAwsProxyHandler(SpringBootLambdaContainerHandler.java:77)
at com.techprimers.serverless.services.AWSLambdaHandler.handleRequest(AWSLambdaHandler.java:172)
... 7 more
Caused by: java.lang.ClassNotFoundException: javax.servlet.ServletContainerInitializer
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 23 more
at line - "handler = SpringBootLambdaContainerHandler.getAwsProxyHandler(Application.class);"
Please HELP me resolve this, I tried various ways of boot setup with aws lambda but failed every time. Please help me fix this or help me out in setting up in any other way. Thanks.
In your logs we can see :
NoClassDefFoundError: javax/servlet/ServletContainerInitializer
ClassNotFoundException: javax.servlet.ServletContainerInitializer
Could you please check if libs are loaded , there must be something missing and not loaded up correctly
Also, something like this has been done
<dependency>
<groupId>com.amazonaws.serverless</groupId>
<artifactId>aws-serverless-java-container-spring</artifactId>
<version>1.3.2</version>
</dependency>
Also double check steps in :
https://github.com/awslabs/aws-serverless-java-container/wiki/Quick-start---Spring-Boot
I had the same issue. I was using version 0.2 of aws-serverless-java-container-spring and had to switch to version 1.3.2 as the former version didn't have SpringBootLambdaContainerHandler class.
Hi I am having a springboot application. while trying to run a junit spring integration test i am getting an error.
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.openmind.primecast.config.LoggingConfiguration$$EnhancerBySpringCGLIB$$4afbeba5]: Constructor threw exception; nested exception is java.lang.LinkageError: loader constraint violation: loader (instance of org/powermock/core/classloader/MockClassLoader) previously initiated loading for a different type with name "javax/net/SocketFactory"
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:154)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:122)
at org.springframework.beans.factory.support.ConstructorResolver$1.run(ConstructorResolver.java:265)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:262)
... 50 common frames omitted
Caused by: java.lang.LinkageError: loader constraint violation: loader (instance of org/powermock/core/classloader/MockClassLoader) previously initiated loading for a different type with name "javax/net/SocketFactory"
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at org.powermock.core.classloader.MockClassLoader.loadUnmockedClass(MockClassLoader.java:262)
at org.powermock.core.classloader.MockClassLoader.loadModifiedClass(MockClassLoader.java:206)
at org.powermock.core.classloader.DeferSupportingClassLoader.loadClass1(DeferSupportingClassLoader.java:89)
at org.powermock.core.classloader.DeferSupportingClassLoader.loadClass(DeferSupportingClassLoader.java:79)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at com.openmind.primecast.config.LoggingConfiguration.addLogstashAppender(LoggingConfiguration.java:66)
at com.openmind.primecast.config.LoggingConfiguration.<init>(LoggingConfiguration.java:49)
at com.openmind.primecast.config.LoggingConfiguration$$EnhancerBySpringCGLIB$$4afbeba5.<init>(<generated>)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:142)
... 54 common frames omitted
this is my junit test class
#RunWith(PowerMockRunner.class)
#PowerMockIgnore({"javax.management.*", "javax.net.ssl.*"})
#SpringBootTest(classes = PrimecastApp.class)
#PowerMockRunnerDelegate(SpringRunner.class)
#PrepareForTest(com.openmind.primecast.security.SecurityUtils.class)
#WithMockUser
public class CampaignResourceIntTest extends AbstractCassandraTest {
#Test
#WithMockUser
public void getCsvForPerformanceNotFound() throws Exception {
PowerMockito.mockStatic(com.openmind.primecast.security.SecurityUtils.class);
BDDMockito.given(com.openmind.primecast.security.SecurityUtils.getCurrentUserLogin()).willReturn(Optional.of(user.getLogin()));
UserDTO userDto = new UserDTO();
userDto.setAccount(null);
when(userService.getUserWithAuthoritiesByLogin(anyString())).thenReturn(userDto);
restCampaignMockMvc.perform(get("/api/campaigns/{id}/performance/csv", UUID.randomUUID()))
.andExpect(status().isNotFound());
}
}
i have no clue . I am using this in my test #PowerMockIgnore({"javax.management.", "javax.net.ssl."})
really appreciate any help
thank you
When cloning this project https://github.com/artem-zinnatullin/droidcon-nyc-2017-puzzlers.git
The project failed to build and I got an error.
It seems like the problem in rxjava lib but i cannot find out.
class MediumRxPuzzler2 {
// What will be printed and why?
#Test
fun puzzler() {
val observer = object : Observer<Int> {
override fun onSubscribe(d: Disposable) = Unit
override fun onNext(t: Int) {
println("onNext $t")
}
override fun onComplete() {
println("onComplete")
}
override fun onError(e: Throwable) {
println("onError $e")
}
}
Observable.just(1).subscribe(observer)
Observable.just(2).subscribe(observer)
}
// What will be printed and why?
#Test
fun `same puzzler?`() {
val observer = object : DefaultObserver<Int>() {
override fun onNext(t: Int) {
println("onNext $t")
}
override fun onComplete() {
println("onComplete")
}
override fun onError(e: Throwable) {
println("onError $e")
}
}
Observable.just(1).subscribe(observer)
Observable.just(2).subscribe(observer)
}
}
Error:Kotlin: [Internal Error] java.lang.IllegalStateException: java.io.FileNotFoundException: D:\droidcon-nyc-2017-puzzlers\puzzlers\build\classes\java\test\com\lyft\droidconnyc2017\puzzlers\rxjava\wth\WthRxPuzzler1$is there any difference 1?$inner$1.class (The filename, directory name, or volume label syntax is incorrect)
at org.jetbrains.kotlin.codegen.CompilationErrorHandler.lambda$static$0(CompilationErrorHandler.java:24)
at org.jetbrains.kotlin.codegen.PackageCodegenImpl.generate(PackageCodegenImpl.java:74)
at org.jetbrains.kotlin.codegen.KotlinCodegenFacade.generatePackage(KotlinCodegenFacade.java:99)
at org.jetbrains.kotlin.codegen.KotlinCodegenFacade.doGenerateFiles(KotlinCodegenFacade.java:77)
at org.jetbrains.kotlin.codegen.KotlinCodegenFacade.compileCorrectFiles(KotlinCodegenFacade.java:44)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.generate(KotlinToJVMBytecodeCompiler.kt:442)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules(KotlinToJVMBytecodeCompiler.kt:153)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:154)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:58)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.java:103)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.java:51)
at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:92)
at org.jetbrains.kotlin.daemon.CompileServiceImpl$compile$$inlined$ifAlive$lambda$1.invoke(CompileServiceImpl.kt:380)
at org.jetbrains.kotlin.daemon.CompileServiceImpl$compile$$inlined$ifAlive$lambda$1.invoke(CompileServiceImpl.kt:96)
at org.jetbrains.kotlin.daemon.CompileServiceImpl$doCompile$$inlined$ifAlive$lambda$2.invoke(CompileServiceImpl.kt:889)
at org.jetbrains.kotlin.daemon.CompileServiceImpl$doCompile$$inlined$ifAlive$lambda$2.invoke(CompileServiceImpl.kt:96)
at org.jetbrains.kotlin.daemon.common.DummyProfiler.withMeasure(PerfUtils.kt:137)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.checkedCompile(CompileServiceImpl.kt:916)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.doCompile(CompileServiceImpl.kt:888)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:378)
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:498)
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$0(TCPTransport.java:683)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.FileNotFoundException: D:\droidcon-nyc-2017-puzzlers\puzzlers\build\classes\java\test\com\lyft\droidconnyc2017\puzzlers\rxjava\wth\WthRxPuzzler1$is there any difference 1?$inner$1.class (The filename, directory name, or volume label syntax is incorrect)
at java.io.FileOutputStream.open0(Native Method)
at java.io.FileOutputStream.open(FileOutputStream.java:270)
at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
at com.intellij.openapi.util.io.FileUtil.writeToFile(FileUtil.java:1282)
at com.intellij.openapi.util.io.FileUtil.writeToFile(FileUtil.java:1276)
at com.intellij.openapi.util.io.FileUtil.writeToFile(FileUtil.java:1261)
at org.jetbrains.kotlin.cli.common.output.outputUtils.OutputUtilsKt.writeAll(outputUtils.kt:32)
at org.jetbrains.kotlin.cli.common.output.outputUtils.OutputUtilsKt.writeAll(outputUtils.kt:42)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.writeOutput(KotlinToJVMBytecodeCompiler.kt:99)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.access$writeOutput(KotlinToJVMBytecodeCompiler.kt:68)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$createOutputFilesFlushingCallbackIfPossible$1.invoke(KotlinToJVMBytecodeCompiler.kt:108)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$createOutputFilesFlushingCallbackIfPossible$1.invoke(KotlinToJVMBytecodeCompiler.kt:68)
at org.jetbrains.kotlin.codegen.state.GenerationStateKt$GenerationStateEventCallback$1.invoke(GenerationState.kt:250)
at org.jetbrains.kotlin.codegen.state.GenerationStateKt$GenerationStateEventCallback$1.invoke(GenerationState.kt:249)
at org.jetbrains.kotlin.codegen.state.GenerationState.afterIndependentPart(GenerationState.kt:206)
at org.jetbrains.kotlin.codegen.PackageCodegenImpl.generate(PackageCodegenImpl.java:67)
... 35 more
This is a bug only on Windows
https://youtrack.jetbrains.com/issue/KT-17438
I am using MySQL 5.5 and mysql-connector-java-5.1.15.(both are Installed new)
I tried a JDBC Program by using Notepad and Command Prompt.
My JDBC Program:
import java.sql.*;
import java.io.*;
public class MysqlConnect{
public static void main(String[] args) {
System.out.println("MySQL Connect Example.");
Connection conn = null;
String url = "jdbc:mysql://localhost:3306/";
String dbName = "employement";
String driver = "com.mysql.jdbc.Driver";
String userName = "root";
String password = "12345";
try {
Class.forName(driver).newInstance();
conn = DriverManager.getConnection(url+dbName,userName,password);
System.out.println("Connected to the database");
conn.close();
System.out.println("Disconnected from database");
} catch (Exception e) {
e.printStackTrace();
}
}
}
I have created a database named employement in mysql....
I try to run this Program...
C:\Users\Innodea\Desktop>javac MysqlConnect.java
C:\Users\Innodea\Desktop>java MysqlConnect
Exception in thread "main" java.lang.NoClassDefFoundError: MysqlConnect
Caused by: java.lang.ClassNotFoundException: MysqlConnect
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: MysqlConnect. Program will exit.
How to clear this error?
Also I have tried as follows,
C:\Users\Innodea\Desktop>set classpath=C:\Program Files\MySQL\mysql-connector-ja
va-5.1.15\mysql-connector-java-5.1.15.jar
C:\Users\Innodea\Desktop>javac MysqlConnect.java
C:\Users\Innodea\Desktop>java MysqlConnect
Exception in thread "main" java.lang.NoClassDefFoundError: MysqlConnect
Caused by: java.lang.ClassNotFoundException: MysqlConnect
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: MysqlConnect. Program will exit.
Again also same error occurs please Help me to clear this error and Run JDBC Program....
java -cp .;C:\Program Files\MySQL\mysql-connector-java-5.1.15\mysql-connector-java-5.1.15.jar MysqlConnect
try using this -
java -cp %CLASSPATH%;.; MysqlConnect.java
Or add . to your classpath to read it like
set classpath=C:\Program Files\MySQL\mysql-connector-ja va-5.1.15\mysql-connector-java-5.1.15.jar;.;
Your current class also needs to be on classpath and hence the dot - current directory.
Using the -cp switch should work
java -cp=.;C:\Program Files\MySQL\mysql-connector-java-5.1.15\mysql-connector-java-5.1.15.jar MysqlConnect
It is almost never needed to set the CLASSPATH environment variable