Compilation error "cannot find symbol" [closed] - java

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
I am trying to insert data into MySQL and I'm getting an error:
cannot find symbol c
import java.sql.*;
class Insert{
public static void main(String args[]){
try{
Class.forName("com.jdbc.mysql.Driver");
Connection c = DriverManager.getConnection("jdbc:mysql://localhost:3036/db","ravi","ravi");
//showing error in the below statement at c
Statement stmt = c.CreateStatement();
int result=stmt.executeUpdate("Insert into emp values(3,'david',33) ");
System.out.println("success");
c.close();
} catch(Exception e) {
System.out.println(e);
}
}
}

It's c.createStatement() and not c.CreateStatement().
You need to make that c to lowercase in the method name createStatement()

Related

java.lang.Error am i missing something in the code? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
This is just a simple query if anyone knows why I am facing this error I would appreciate the help.
The problem is simple java if else if else loop problem .
so I tried to make syntax as correct as possible.
The code here below is the one I am executing.
public class ifelseloop {
public static void main(String[] args){
// int a = 20;
// int b = 20;
String city = "Delhi";
if (city == "madras") {
System.out.println("the city is not delhi its madras");
}else if(city == "chennai") {
System.out.println("the city is not delhi its chennai");
}else if(city == "bartar") {
System.out.println("the city is bartar");
}else {
System.out.println(city);
}
}
}
and the error that I am getting is this.
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
at ifelseloop.main(ifelseloop.java:2)

Simple Java Recursion Method [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 years ago.
Improve this question
What is the wrong of this code? need help.
public class TailRrecursion {
public static void tail(int i) {
if (i > 0) {
System.out.print(i + "");
tail(i - 1);
}
}
}
For a start, you are missing curly { braces
see
public class Tail-recursion{
public static void tail(int i) {
if(i>0){
System.out.print (i +"");
tail(i-1);
}
}
} // and here

output is not showing at output screen [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
public class Try1 {
public static void main(String[] args) {
char ch;
for(ch='a' ;ch<='z'; ch++);
{
System.out.println(ch);
}
}
}
could not get output
try
public static void main(String[] args) {
char ch;
for(ch='a' ;ch<='z'; ch++)
{
System.out.println(ch);
}
}
You've used ; after for loop.
for this "for(ch='a' ;ch<='z'; ch++);" statement, are you sure about last semicolumn, it breaks your for loop right there only.

String Input line 4 Error, I cannot seem to figure out what it is [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
import java.io.*;
public class StringInput{
public static void main (String args[]);{
String Name "StringInput";
System.out.print ("Enter your name: ");
InputStreamReader input = new InputStreamReader(System.in);
InputStreamReader reader = new BufferedReader(input);
name = reader.readline();
catchException e;{
}//Exception
System.out.println ("Hello"+Name+"How are you?");
}//main
}//class
That is the code that I was doing, theres one error. Line 4, I can't figure out what it is.
We were doing it in class (I just started Computer Programming 12) and we didn't have time to finish it and everything.
If someone could help me figure out what is wrong with line 4 that'd be really helpful.
Thanks ! :)
Removed the semi colon, still get String Name "StringInput";
^
1 error
Process completed.
Remove the semicolon(;) after main method:
Change this:
public static void main (String args[]);{
to
public static void main (String args[]) {
Another error in your code is related to try/catch usage:
Change this:
name = reader.readline();
catchException e;{
}//Exception
to
try {
name = reader.readline();
catch(Exception e){
e.printStackTrace();
}//Exception
Final Note: Learn the language syntax first before jumping to coding.

Cannot find i in the for loop [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 9 years ago.
Improve this question
I can't seem to get the last "i" in this code to fully function, it wont respond to the initial "i", just tells me that it "cannot find symbol". What am I doing wrong?
public void fillCB (JComboBox cb){
String sqlQueryCB = "select namn from ANSTALLD order by namn";
try {
ArrayList<String> listaAnstalld = idb.fetchColumn(sqlQueryCB);
for(int i = 0; i < listaAnstalld.size(); i++); {
cb.addItem(listaAnstalld.get(i));
}
}
catch(Exception e)
{
}
you have a semicolon at the end of your for loop, before the opening brace.
for(int i = 0; i < listaAnstalld.size(); i++); {
That semicolon closes the for loop. should remove it.
because of this, the contents of your block will not be in the scope of the for loop(and therefore not in the same scope that i is in).

Categories